@arcgis/map-components
Version:
ArcGIS Map Components
3 lines (2 loc) • 6.95 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import{M as x,N as w,O as P,U as F,a as C,b as t,f as U,x as f}from"./WUJCCZQC.js";import"./3TTFCHAA.js";var N=C`:host{min-height:var(--arcgis-internal-panel-height-md, 420px);height:100%}calcite-block{margin-block:0;width:100%}calcite-pagination{justify-content:center;background-color:var(--calcite-color-surface-2)}.filter-container{width:100%}.fab-container{background-color:var(--calcite-color-surface-2);display:flex;justify-content:center}`,k=class extends P{constructor(){super(...arguments),this._filterInputElement=x(),this._flowItemElement=x(),this.currentPage=1,this.selected=!1,this.showBackButton=!1,this.arcgisFlowItemBack=f(),this.arcgisFlowItemClose=f(),this.arcgisGetVersions=f(),this.arcgisManageVersion=f(),this.arcgisNewVersion=f()}static{this.properties={_filteredVersionInfos:16,currentPage:11,selected:7,showBackButton:7,versionListElementProps:0}}static{this.styles=N}load(){this._filteredVersionInfos=this.versionListElementProps.versionInfos}willUpdate(e){if(e.has("versionListElementProps")){let i=e.get("versionListElementProps"),s=this.versionListElementProps;i?.versionInfos!==s.versionInfos&&(this._filteredVersionInfos=s.versionInfos,this._filterInputElement.value&&this._handleFilterChange())}}updated(){this._filterInputElement.value?.setFocus()}async setFocus(){this._flowItemElement.value?.setFocus()}goBack(){}_handleFilterChange(){let{versionListElementProps:{versionInfos:e}}=this,i=this._filterInputElement.value.value.toUpperCase();this._filteredVersionInfos=i===""?e:e.filter(s=>s.versionIdentifier.name.toUpperCase().includes(i)||s.versionIdentifier.guid.toUpperCase().includes(i)),this._filteredVersionInfos.length&&(this.currentPage=1)}_handleNoticeClosed(){this.versionListElementProps={...this.versionListElementProps,executionError:void 0}}_handlePaginationChange(e){this.currentPage=e.target.startItem}_getExecutionError(e){let{versionListElementProps:{strings:{executionErrors:i}}}=this;switch(e){case"no-feature-service-found":return i.noFeatureServiceFound;case"no-valid-enterprise-version":return i.notValidEnterpriseVersion;case"no-valid-version-name":return i.invalidVersionName;default:return e}}_paginate(e,i,s){return e.slice((s-1)*i,s*i)}render(){let{currentPage:e,selected:i,showBackButton:s,versionListElementProps:{closable:m,currentUser:u,currentVersionIdentifier:d,executionError:h,heading:r,isVersionAdministrator:g,isVersioningApiAvailable:v,pageSize:o,serviceName:n,serviceUrl:c,state:p,strings:{headers:l},strings:a,versionInfos:$}}=this,I=t`<calcite-block .description=${d.name} .heading=${l.currentVersion} overlay-positioning=fixed scale=s></calcite-block>`,V=t`<calcite-action icon=refresh .id=${`action-refresh-versions-${n}`} .label=${`action-refresh-versions-${n}`} slot=header-actions-end text @click=${()=>this.arcgisGetVersions.emit({serviceUrl:c})}><calcite-tooltip overlay-positioning=fixed .referenceElement=${`action-refresh-versions-${n}`}><span>${a.actions.refreshVersions}</span></calcite-tooltip></calcite-action>`;this._paginatedVersionInfos=this._filteredVersionInfos.length>o?this._paginate(this._filteredVersionInfos,o,e):this._filteredVersionInfos;let b=this._filteredVersionInfos.length>o?t`<calcite-pagination @calcitePaginationChange=${this._handlePaginationChange} page-size=1 .startItem=${e} .totalItems=${Math.ceil(this._filteredVersionInfos.length/o)}></calcite-pagination>`:void 0,_=this._paginate(this._paginatedVersionInfos,o,1).map(A=>{let M={currentUser:u,currentVersionIdentifier:d,isCurrentVersionCard:!1,isVersionAdministrator:g,isVersioningApiAvailable:v,serviceUrl:c,strings:a,versionInfo:A};return this._renderListItem(M)}),E=$.length>o?t`<div class="filter-container" slot=content-top><calcite-input-text clearable icon=search .label=${l.filterVersions} @calciteInputTextInput=${this._handleFilterChange} .placeholder=${a.actions.searchVersions} ${w(this._filterInputElement)}></calcite-input-text></div>`:void 0,L=t`<calcite-list .label=${a.labels.versionList}>${_}</calcite-list>`,y=v?t`<div class="fab-container"><calcite-fab appearance=outline-fill text-enabled .text=${a.actions.newVersion} @click=${()=>this.arcgisNewVersion.emit({serviceUrl:c})}></calcite-fab></div>`:void 0,B=h?t`<calcite-notice @calciteNoticeClose=${this._handleNoticeClosed} closable kind=warning open scale=s width=full><div slot=message>${this._getExecutionError(h)}</div></calcite-notice>`:void 0;return t`<calcite-flow-item .closable=${m} .description=${n} .heading=${r} .selected=${i} .showBackButton=${s} @calciteFlowItemBack=${()=>this.arcgisFlowItemBack.emit()} @calciteFlowItemClose=${()=>this.arcgisFlowItemClose.emit()} ${w(this._flowItemElement)}><calcite-panel .loading=${p==="executing"}>${I}<calcite-panel .heading=${this._filteredVersionInfos.length?`${a.headers.manageVersions} (${this._filteredVersionInfos.length})`:a.headers.manageVersions} scale=s>${V}${E}${L}${y}${b}</calcite-panel>${B}</calcite-panel></calcite-flow-item>`}_renderListItem(e){let{currentUser:i,currentVersionIdentifier:s,isVersionAdministrator:m,isVersioningApiAvailable:u,serviceUrl:d,strings:{actions:h},versionInfo:r}=e,g=r.versionIdentifier.name,v=g.substring(g.lastIndexOf(".")+1),o=g.substring(0,g.lastIndexOf(".")),n=r.versionIdentifier.guid,c=`action-start-switch-to-version-${n}`,p=o.toUpperCase()===i.toUpperCase()&&u||m,l=s.guid===r.versionIdentifier.guid,a=g.toUpperCase()==="SDE.DEFAULT",$=t`<calcite-action .disabled=${l} icon=code-branch .label=${`action-switch-to-version-${n}`} scale=s .text=${h.switchToVersion} text-enabled @click=${()=>{this.arcgisManageVersion.emit({actionType:"changeVersion",serviceUrl:d,versionInfo:r})}}></calcite-action>`,I=a?void 0:t`<calcite-action .disabled=${!p||p&&l} icon=trash .label=${`action-delete-version-${n}`} scale=s .text=${h.deleteVersion} text-enabled @click=${()=>{this.arcgisManageVersion.emit({actionType:"deleteVersion",serviceUrl:d,versionInfo:r})}}></calcite-action>`,V=t`<calcite-action .disabled=${!p||l} icon=code-branch-edit .label=${`action-edit-version-${n}`} scale=s .text=${h.editVersion} text-enabled @click=${()=>{this.arcgisManageVersion.emit({actionType:"editVersion",serviceUrl:d,versionInfo:r})}}></calcite-action>`,b=t`<calcite-action-menu .label=${`action-version-menu-${n}`} overlay-positioning=fixed slot=actions-end>${$}${V}${I}</calcite-action-menu>`,_=l?void 0:t`<calcite-tooltip overlay-positioning=fixed .referenceElement=${c}><span>${h.switchToVersion}</span></calcite-tooltip>`,E=t`<div slot=actions-start><calcite-action .disabled=${l} icon=code-branch id=${c??U} .label=${c} .text=${c} @click=${()=>{this.arcgisManageVersion.emit({actionType:"changeVersion",serviceUrl:d,versionInfo:r})}}></calcite-action>${_}</div>`;return t`<calcite-list-item .description=${o} .label=${v} .value=${n}>${E}${b}</calcite-list-item>`}};F("arcgis-version-management-version-list",k);export{k as ArcgisVersionManagementVersionList};