UNPKG

@arcgis/map-components

Version:
104 lines (103 loc) 6.03 kB
import { c as y } from "../../chunks/runtime.js"; import { html as s } from "lit"; import { createRef as g, ref as p } from "lit-html/directives/ref.js"; import { LitElement as F, createEvent as a } from "@arcgis/lumina"; import { css as U } from "@lit/reactive-element/css-tag.js"; /*! All material copyright Esri, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. v4.32.14 */ const A = U`:host{display:none;background:#bdf2c4}:host([selected]){display:flex}calcite-block{margin-block:0}calcite-pagination{justify-content:center}`; class N extends F { constructor() { super(...arguments), this._filterInputElement = g(), this._flowItemElement = g(), this.currentPage = 1, this.selected = !1, this.showBackButton = !1, this.arcgisGetVersions = a(), this.arcgisManageVersion = a(), this.arcgisNewVersion = a(); } static { this.properties = { _filteredVersionInfos: 16, currentPage: 11, selected: 7, showBackButton: 7, versionListElementProps: 0 }; } static { this.styles = A; } //#endregion //#region Lifecycle load() { this._filteredVersionInfos = this.versionListElementProps.versionInfos; } willUpdate(e) { if (e.has("versionListElementProps")) { const t = e.get("versionListElementProps"), i = this.versionListElementProps; t?.versionInfos !== i.versionInfos && (this._filteredVersionInfos = i.versionInfos, this._filterInputElement.value && this._handleFilterChange()); } } updated() { this._filterInputElement.value?.setFocus(); } //#endregion //#region Private Methods async setFocus() { this._flowItemElement.value?.setFocus(); } // eslint-disable-next-line @typescript-eslint/no-empty-function goBack() { } _handleFilterChange() { const { versionListElementProps: { versionInfos: e } } = this, t = this._filterInputElement.value.value.toUpperCase(); this._filteredVersionInfos = t === "" ? e : e.filter((i) => i.versionIdentifier.name.toUpperCase().includes(t) || i.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-advanced-editing-user-type-extension": return t.noAdvancedEditingUserTypeExtension; 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, i) { return e.slice((i - 1) * t, i * t); } //#endregion //#region Rendering render() { const { currentPage: e, selected: t, showBackButton: i, versionListElementProps: { closable: m, currentUser: u, currentVersionIdentifier: l, executionError: c, hasAdvEditingUte: h, heading: v, isVersionAdministrator: V, isVersioningApiAvailable: d, pageSize: o, serviceName: I, serviceUrl: r, state: E, strings: { headers: f }, strings: n, versionInfos: $ } } = this, _ = s`<calcite-block .heading=${f.currentVersion} .description=${l.name} overlay-positioning=fixed></calcite-block>`, P = s`<calcite-action id=actionRefreshVersions icon=refresh text @click=${() => { this.arcgisGetVersions.emit({ serviceUrl: r }); }} slot=header-actions-end><calcite-tooltip overlay-positioning=fixed reference-element=actionRefreshVersions><span>${n.actions.refreshVersions}</span></calcite-tooltip></calcite-action>`; this._paginatedVersionInfos = this._filteredVersionInfos.length > o ? this._paginate(this._filteredVersionInfos, o, e) : this._filteredVersionInfos; const x = this._filteredVersionInfos.length > o ? s`<calcite-pagination @calcitePaginationChange=${this._handlePaginationChange} page-size=1 .startItem=${e} .totalItems=${Math.ceil(this._filteredVersionInfos.length / o)}></calcite-pagination>` : void 0, b = this._paginate(this._paginatedVersionInfos, o, 1).map((B) => s`<arcgis-version-management-version-item .versionItemElementProps=${{ currentUser: u, currentVersionIdentifier: l, isCurrentVersionCard: !1, hasAdvEditingUte: h, isVersionAdministrator: V, isVersioningApiAvailable: d, serviceUrl: r, strings: n, versionInfo: B }}></arcgis-version-management-version-item>`), w = $.length > o ? s`<calcite-block heading .label=${f.filterVersions} open><calcite-input-text clearable icon=search @calciteInputTextInput=${this._handleFilterChange} .placeholder=${n.actions.searchVersions} ${p(this._filterInputElement)}></calcite-input-text></calcite-block>` : void 0, k = s`<calcite-list .label=${n.headers.manageVersions}>${b}</calcite-list>`, C = d && h ? s`<calcite-fab appearance=outline-fill slot=fab text-enabled .text=${n.actions.newVersion} @click=${() => { this.arcgisNewVersion.emit({ serviceUrl: r }); }}></calcite-fab>` : void 0, L = c ? s`<calcite-notice @calciteNoticeClose=${this._handleNoticeClosed} class="notice" closable kind=warning open scale=s slot=footer width=full><div slot=message>${this._getExecutionError(c)}</div></calcite-notice>` : void 0; return s`<calcite-flow-item .closable=${m} .description=${I} .heading=${v} .selected=${t} .showBackButton=${i} ${p(this._flowItemElement)}><calcite-panel .loading=${E === "executing"}>${_}<calcite-panel .heading=${this._filteredVersionInfos.length ? `${n.headers.manageVersions} (${this._filteredVersionInfos.length})` : n.headers.manageVersions}>${P}${w}${k}${C}</calcite-panel>${x}${L}</calcite-panel></calcite-flow-item>`; } } y("arcgis-version-management-version-list", N); export { N as ArcgisVersionManagementVersionList };