UNPKG

@arcgis/map-components

Version:
3 lines (2 loc) 5.78 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import{M as u,N as v,O as b,U as w,a as g,b as l,x as p}from"./WUJCCZQC.js";import"./3TTFCHAA.js";var x=g`:host{min-height:var(--arcgis-internal-panel-height-md, 420px);height:100%}`,_=class extends b{constructor(){super(...arguments),this._flowItemElement=u(),this._switchToVersion=!0,this._switchToVersionCheckboxElement=u(),this._versionNameInputElement=u(),this.selected=!1,this.showBackButton=!1,this.arcgisAlterVersion=p(),this.arcgisCreateVersion=p(),this.arcgisFlowItemBack=p(),this.arcgisFlowItemClose=p()}static{this.properties={_validationError:16,selected:7,showBackButton:7,versionPropertiesElementProps:0}}static{this.styles=x}load(){let{versionPropertiesElementProps:{versionInfo:t}}=this;t?(this._mode="edit",this._fullVersionName=t.versionIdentifier.name,this._ownerName=this._fullVersionName.substring(0,this._fullVersionName.lastIndexOf(".")),this._versionName=this._fullVersionName.substring(this._fullVersionName.lastIndexOf(".")+1)):this._mode="create"}updated(){this._mode==="create"&&this._versionNameInputElement.value?.setFocus()}async setFocus(){this._flowItemElement.value?.setFocus()}goBack(){}_handleCancel(){this.arcgisFlowItemBack.emit()}_handleChange(t){let{_mode:i,_ownerName:h,_versionName:d,versionPropertiesElementProps:{currentUser:m,isVersionAdministrator:e,serviceUrl:s,versionInfo:c}}=this,{_alterVersionParameters:n,_createVersionParameters:a}=this;switch(i==="create"&&(a||(a={access:"public",description:"",featureServerUrl:s,ownerName:m,versionName:""})),i==="edit"&&(n||(n={featureServerUrl:s,versionIdentifier:c.versionIdentifier,ownerName:h,versionName:d,access:c.access,description:c.description})),t.type){case"calciteChipGroupSelect":{let r=t.target.label,o=t.target.selectedItems[0].label;i==="create"&&(a={...a,[r]:o}),i==="edit"&&(n={...n,[r]:o});break}case"calciteInputTextInput":{let r=t.target.name,o=t.target.value;i==="create"&&(a={...a,[r]:o}),i==="edit"&&(n={...n,[r]:o});break}case"calciteTextAreaInput":{let r=t.target.name,o=t.target.value;i==="create"&&r&&(a={...a,[r]:o}),i==="edit"&&r&&(n={...n,[r]:o});break}}i==="create"&&(a.access!=="public"&&m.toUpperCase()!==a.ownerName?.toUpperCase()&&!e?(this._switchToVersionCheckboxElement.value.checked=!1,this._switchToVersionCheckboxElement.value.disabled=!0,this._switchToVersion=!1):this._switchToVersionCheckboxElement.value.disabled=!1,this._createVersionParameters=a),i==="edit"&&(this._alterVersionParameters=n)}_handleClose(){this.arcgisFlowItemClose.emit()}_handleSave(){let{_alterVersionParameters:t,_createVersionParameters:i,_mode:h,_switchToVersion:d,versionPropertiesElementProps:{strings:m}}=this,e=[".",";","'",'"'];if(e.some(s=>i?.versionName?.includes(s))||e.some(s=>t?.versionName?.includes(s))){this._validationError=m.validationErrors.invalidCharacters;return}h==="create"&&this.arcgisCreateVersion.emit({createVersionParameters:i,switchToVersion:d}),h==="edit"&&this.arcgisAlterVersion.emit({alterVersionParameters:t})}_handleSwitchToVersionChange(t){this._switchToVersion=t.target.checked}render(){let{selected:t,showBackButton:i,versionPropertiesElementProps:{closable:h,currentUser:d,state:m,strings:e,versionInfo:s},_mode:c,_ownerName:n,_versionName:a}=this,r=l`<calcite-button appearance=outline slot=footer width=full @click=${this._handleCancel}>${e.actions.cancelSave}</calcite-button><calcite-button appearance=solid slot=footer width=full @click=${this._handleSave}>${e.actions.saveVersion}</calcite-button>`,o=l`<calcite-label>${e.input.versionAccess}<calcite-chip-group label=access @calciteChipGroupSelect=${this._handleChange} selection-mode=single-persist><calcite-chip .selected=${c==="edit"&&s.access==="public"||c==="create"} label=public>${e.accessLevels.public}</calcite-chip><calcite-chip .selected=${c==="edit"&&s.access==="protected"} label=protected>${e.accessLevels.protected}</calcite-chip><calcite-chip .selected=${c==="edit"&&s.access==="private"} label=private>${e.accessLevels.private}</calcite-chip></calcite-chip-group></calcite-label>`,$=l`<calcite-label>${e.input.versionDescription}<calcite-text-area limit-text max-length=64 name=description resize=none rows=2 scale=s .value=${c==="edit"?s.description:""} @calciteTextAreaInput=${this._handleChange}></calcite-text-area></calcite-label>`,V=l`<calcite-label>${e.input.versionName}<calcite-input-text max-length=62 name=versionName .value=${c==="edit"?a:""} @calciteInputTextInput=${this._handleChange} ${v(this._versionNameInputElement)}></calcite-input-text></calcite-label>`,f=l`<calcite-label>${e.input.versionOwner}<calcite-input-text name=ownerName .value=${c==="edit"?n:d} @calciteInputTextInput=${this._handleChange}></calcite-input-text></calcite-label>`,C=c==="create"?l`<calcite-label layout=inline><calcite-checkbox checked name=switchToVersion @calciteCheckboxChange=${this._handleSwitchToVersionChange} ${v(this._switchToVersionCheckboxElement)}></calcite-checkbox>${e.actions.switchToVersion}</calcite-label>`:void 0,I=this._validationError?l`<calcite-notice closable kind=warning open scale=s width=full @calciteNoticeClose=${()=>this._validationError=void 0}><div slot=message>${this._validationError}</div></calcite-notice>`:void 0;return l`<calcite-flow-item .closable=${h} .description=${s?s.versionIdentifier.name:""} .heading=${s?e.actions.editVersion:e.actions.newVersion} .selected=${t} .showBackButton=${i} @calciteFlowItemClose=${this._handleClose} ${v(this._flowItemElement)}><calcite-panel .loading=${m==="executing"}><calcite-block expanded .label=${e.headers.versionProperties}>${V}${$}${o}${f}${C}${I}</calcite-block>${r}</calcite-panel></calcite-flow-item>`}};w("arcgis-version-management-version-properties",_);export{_ as ArcgisVersionManagementVersionProperties};