@arcgis/map-components
Version:
ArcGIS Map Components
104 lines (103 loc) • 6.74 kB
JavaScript
import { c as $ } from "../../chunks/runtime.js";
import { html as n } from "lit-html";
import { createRef as u, ref as f } from "lit-html/directives/ref.js";
import { LitElement as V, createEvent as p, noShadowRoot as I } from "@arcgis/lumina";
import { css as x } 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 C = x`{:host{display:none;background:#bdf2c4}:host([selected]){display:flex}.properties-buttons{display:flex}}`;
class k extends V {
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 = { selected: 7, showBackButton: 7, versionPropertiesElementProps: 0 };
}
static {
this.shadowRootOptions = I;
}
static {
this.styles = C;
}
//#endregion
//#region Lifecycle
load() {
const { 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();
}
//#endregion
//#region Private Methods
async setFocus() {
this._flowItemElement.value?.setFocus();
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
goBack() {
}
_handleCancel() {
this.arcgisFlowItemBack.emit();
}
_handleChange(t) {
const { _mode: s, _ownerName: l, _versionName: h, versionPropertiesElementProps: { currentUser: m, isVersionAdministrator: d, serviceUrl: i, versionInfo: c } } = this;
let { _alterVersionParameters: e, _createVersionParameters: a } = this;
switch (s === "create" && (a || (a = {
access: "public",
description: "",
featureServerUrl: i,
ownerName: m,
versionName: ""
})), s === "edit" && (e || (e = {
featureServerUrl: i,
versionIdentifier: c.versionIdentifier,
ownerName: l,
versionName: h,
access: c.access,
description: c.description
})), t.type) {
case "calciteChipGroupSelect": {
const r = t.target.label, o = t.target.selectedItems[0].label;
s === "create" && (a = { ...a, [r]: o }), s === "edit" && (e = { ...e, [r]: o });
break;
}
case "calciteInputTextInput": {
const r = t.target.name, o = t.target.value;
s === "create" && (a = { ...a, [r]: o }), s === "edit" && (e = { ...e, [r]: o });
break;
}
case "calciteTextAreaInput": {
const r = t.target.name, o = t.target.value;
s === "create" && (a = { ...a, [r]: o }), s === "edit" && (e = { ...e, [r]: o });
break;
}
}
s === "create" && (a.access !== "public" && m.toUpperCase() !== a.ownerName?.toUpperCase() && !d ? (this._switchToVersionCheckboxElement.value.checked = !1, this._switchToVersionCheckboxElement.value.disabled = !0, this._switchToVersion = !1) : this._switchToVersionCheckboxElement.value.disabled = !1, this._createVersionParameters = a), s === "edit" && (this._alterVersionParameters = e);
}
_handleClose() {
this.arcgisFlowItemClose.emit();
}
_handleSave() {
const { _alterVersionParameters: t, _createVersionParameters: s, _mode: l, _switchToVersion: h } = this;
l === "create" && this.arcgisCreateVersion.emit({
createVersionParameters: s,
switchToVersion: h
}), l === "edit" && this.arcgisAlterVersion.emit({
alterVersionParameters: t
});
}
_handleSwitchToVersionChange(t) {
this._switchToVersion = t.target.checked;
}
//#endregion
//#region Rendering
render() {
const { selected: t, showBackButton: s, versionPropertiesElementProps: { closable: l, currentUser: h, hasAdvEditingUte: m, state: d, strings: i, versionInfo: c }, _mode: e, _ownerName: a, _versionName: r } = this, o = n`<div class="properties-buttons"><calcite-button appearance=outline width=half =${this._handleCancel}>${i.actions.cancelSave}</calcite-button><calcite-button width=half =${this._handleSave}>${i.actions.saveVersion}</calcite-button></div>`, v = n`<calcite-label>${i.input.versionAccess}<calcite-chip-group label=access =${this._handleChange} selection-mode=single-persist><calcite-chip .selected=${e === "edit" && c.access === "public" || e === "create"} label=public>${i.accessLevels.public}</calcite-chip><calcite-chip .selected=${e === "edit" && c.access === "protected"} label=protected>${i.accessLevels.protected}</calcite-chip><calcite-chip .selected=${e === "edit" && c.access === "private"} label=private>${i.accessLevels.private}</calcite-chip></calcite-chip-group></calcite-label>`, b = n`<calcite-label>${i.input.versionDescription}<calcite-text-area name=description =${this._handleChange} resize=vertical .value=${e === "edit" ? c.description : ""}></calcite-text-area></calcite-label>`, _ = n`<calcite-label>${i.input.versionName}<calcite-input-text name=versionName =${this._handleChange} max-length=62 .value=${e === "edit" ? r : ""} ${f(this._versionNameInputElement)}></calcite-input-text></calcite-label>`, w = n`<calcite-label>${i.input.versionOwner}<calcite-input-text name=ownerName =${this._handleChange} .disabled=${!m} .value=${e === "edit" ? a : h}></calcite-input-text></calcite-label>`, g = e === "create" ? n`<calcite-label layout=inline><calcite-checkbox checked name=switchToVersion =${this._handleSwitchToVersionChange} ${f(this._switchToVersionCheckboxElement)}></calcite-checkbox>${i.actions.switchToVersion}</calcite-label>` : void 0;
return n`<calcite-flow-item .closable=${l} .description=${c ? c.versionIdentifier.name : ""} .heading=${c ? i.actions.editVersion : i.actions.newVersion} .selected=${t} .showBackButton=${s} =${this._handleClose} ${f(this._flowItemElement)}><calcite-panel .loading=${d === "executing"}><calcite-block .label=${i.headers.versionProperties} open>${_}${b}${v}${w}${g}${o}</calcite-block></calcite-panel></calcite-flow-item>`;
}
}
$("arcgis-version-management-version-properties", k);
export {
k as ArcgisVersionManagementVersionProperties
};