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