@arcgis/core 5.1.0-next.112 → 5.1.0-next.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0e6a388d51d9dbae46ba.js → 02c0640005b09007bb70.js} +1 -1
- package/assets/esri/core/workers/chunks/{beff5b4e15edee12bd4c.js → 271e42b7cd3c3441839e.js} +3 -3
- package/assets/esri/core/workers/chunks/32f128a1615d71bbe899.js +2 -0
- package/assets/esri/core/workers/chunks/40df608337d562553ce1.js +2 -0
- package/assets/esri/core/workers/chunks/{711d1873c760313e287f.js → 52a91c314afec70199bc.js} +1 -1
- package/assets/esri/core/workers/chunks/{fe8334352d256d691a95.js → 5c6742728fa705d2e16e.js} +1 -1
- package/assets/esri/core/workers/chunks/{481dc7503587972a6bd2.js → 701125f6cdd91ff3655f.js} +2 -2
- package/assets/esri/core/workers/chunks/7995e6983456c779adf9.js +1 -0
- package/assets/esri/core/workers/chunks/860465c4f44c373d0a1c.js +1 -0
- package/assets/esri/core/workers/chunks/{08efd64acdfe46985293.js → 9a11ff75009fef45b8c1.js} +1 -1
- package/assets/esri/core/workers/chunks/a70fa35b2d19460637e9.js +2 -0
- package/assets/esri/core/workers/chunks/ae74f722fb385e45fcf1.js +1 -0
- package/assets/esri/core/workers/chunks/{b02a68bbab07557cf02d.js → b4badbcf1bdb7823d825.js} +1 -1
- package/assets/esri/core/workers/chunks/b78fb24b47d9f31f18c6.js +1 -0
- package/assets/esri/core/workers/chunks/e95ce76b5b816256a519.js +1 -0
- package/assets/esri/core/workers/chunks/fbcf09526dc1bbe94b91.js +2 -0
- package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +22 -6
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_en.json +1 -1
- package/assets/esri/widgets/Features/t9n/Features_en.json +1 -1
- package/chunks/GaussianSplatShadow.glsl.js +11 -9
- package/chunks/ShadowCastVisualize.glsl.js +26 -18
- package/config.js +1 -1
- package/kernel.js +1 -1
- package/layers/KnowledgeGraphLayer.d.ts +6 -4
- package/layers/KnowledgeGraphLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/support/featureLayerUtils.js +1 -1
- package/linkChart/LinkChartProperties.js +1 -1
- package/linkChart/utils.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/types.d.ts +45 -1
- package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedFillShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedLineShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedDrawToolRenderer.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
- package/views/3d/analysis/Viewshed/viewshedToolManipulatorUtils.js +1 -1
- package/views/3d/environment/EnvironmentManager.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +3 -3
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplatShadow.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.d.ts +17 -3
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/css.js +1 -1
- package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.d.ts +25 -1
- package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
- package/widgets/BatchAttributeForm/inputs/RelationshipElementInput.d.ts +46 -1
- package/widgets/BatchAttributeForm/inputs/RelationshipElementInput.js +1 -1
- package/widgets/BatchAttributeForm/inputs/UtilityNetworkAssociationsElementInput.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
- package/widgets/BatchAttributeForm/interfaceUtils.js +1 -1
- package/widgets/BatchAttributeForm/types.d.ts +1 -1
- package/widgets/BatchAttributeForm.d.ts +2 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
- package/widgets/FeatureForm/RelationshipInput.d.ts +3 -3
- package/widgets/FeatureForm/RelationshipInput.js +1 -1
- package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.d.ts +66 -6
- package/widgets/support/SelectionToolbar/types.d.ts +20 -1
- package/assets/esri/core/workers/chunks/03babc21d1781142a974.js +0 -1
- package/assets/esri/core/workers/chunks/340c68d09d2e8bef6727.js +0 -2
- package/assets/esri/core/workers/chunks/8a1751187a20b6578875.js +0 -1
- package/assets/esri/core/workers/chunks/9ebc461529d5286fa2c2.js +0 -2
- package/assets/esri/core/workers/chunks/aca9591d3467a24f8329.js +0 -1
- package/assets/esri/core/workers/chunks/d00b9c1fd0865bf8f317.js +0 -1
- package/assets/esri/core/workers/chunks/d02aa7438f46c1c2167a.js +0 -2
- package/assets/esri/core/workers/chunks/deab352545c34cac148c.js +0 -1
- package/assets/esri/core/workers/chunks/e5854a3f69dffaf9464d.js +0 -2
- /package/assets/esri/core/workers/chunks/{e5854a3f69dffaf9464d.js.LICENSE.txt → 32f128a1615d71bbe899.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{340c68d09d2e8bef6727.js.LICENSE.txt → 40df608337d562553ce1.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{481dc7503587972a6bd2.js.LICENSE.txt → 701125f6cdd91ff3655f.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{d02aa7438f46c1c2167a.js.LICENSE.txt → a70fa35b2d19460637e9.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{9ebc461529d5286fa2c2.js.LICENSE.txt → fbcf09526dc1bbe94b91.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{pushIfSome as e}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import n from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as c}from"../../core/maybe.js";import{throwIfAborted as h,isAbortError as u}from"../../core/promiseUtils.js";import m from"../../core/ReactiveMap.js";import{on as d,sync as p,watch as g,syncAndInitial as f,initial as A,whenOnce as v}from"../../core/reactiveUtils.js";import{property as y,subclass as F}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as _}from"../../core/support/UpdatingHandles.js";import I from"../../geometry/SpatialReference.js";import{getGraphicLayer as w}from"../../graphic/graphicOriginUtils.js";import{system as E}from"../../time/constants.js";import{getAttachmentKey as x}from"./attachmentUtils.js";import{createReactiveGraphic as M,isAttributeFormSupportedLayerWithAttachments as C,layerSupportsQueryAttachments as k,queryAttachmentsForElements as V}from"./batchAttributeFormUtils.js";import{ReactiveContingentValuesManager as b}from"./ReactiveContingentValuesManager.js";import{ArcadeExecutorProvider as L}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as T}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as S}from"./expressions/ExpressionsModel.js";import j from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as H}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as B,isFieldInput as R}from"./inputs/support/inputUtils.js";import O from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as G}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as U,isGroupElementTemplate as W}from"./templates/support/templateUtils.js";import{ContingentValuesManager as P}from"../support/ContingentValuesManager.js";import{isEmptyValue as N}from"../support/forms/formUtils.js";function Z(t,e){return t?.find(t=>t.layer===e)}let D=class extends a{constructor(t){super(t),this._attachmentCache=new m,this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new n,this._hasAsyncArcadeExpressions=!1,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.map=null,this.pageStack=[],this.readOnly=!1,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new L,this._activeAssociationsInput=null,this._ownContingentValuesManager=null,this._activeFormInputsByElementId=new Map,this._emptyForm=new j({inputs:[]}),this._emptyFormTemplate=new O({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new m,this._updatingHandles=new _,this._layerTemplateMap=new m,this._workingFeatures=new n,this._expressionsManager=new T({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:E}}),this._getFieldValueOptionsForFeature=t=>this._reactiveContingentValuesManager.getAndWatchFieldValueOptions(t),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.contingentValuesManager||(this.contingentValuesManager=this._ownContingentValuesManager=new P),this.addHandles([d(()=>this.features,"after-changes",()=>{this.goHome(),this.notifyChange("layers"),this._prepare()},p),g(()=>[this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),p),g(()=>this.activeForm,()=>{this.goHome(),this._activeFormInputsByElementId.clear(),this._syncAttachments()},p),g(()=>this.activeFeature,()=>{this.goHome()},p),g(()=>this.page,t=>{const e=[...this.pageStack];if(e.includes(t))for(;e.length&&e.at(-1)!==t;)e.pop();else e.push(t);this.pageStack=e},f),g(()=>this.contingentValuesManager,t=>{l(this._reactiveContingentValuesManager),this._reactiveContingentValuesManager=new b({manager:t})},A)]),this._prepare()}destroy(){this._prepareTask=c(this._prepareTask),this._workingFeatures.destroyAll(),l(this._expressionsManager),l(this._reactiveContingentValuesManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new m,this._emptyForm.destroy(),this._emptyFormTemplate.destroy(),this._ownContingentValuesManager=l(this._ownContingentValuesManager)}get activeFeature(){const t=this.activeFeatureIndex;return t<0?null:this.features.at(t)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const t=this._workingFeatures.at(this.activeFeatureIndex);if(!t)return this._emptyForm;const e=this._featureFormMap.get(t);if(e)return e;const s=this._makeBatchFormInputsForFeature(t);return s!==this._emptyForm&&this._featureFormMap.set(t,s),s}get activeLayer(){const{activeFeature:t}=this;if(!t)return null;return w(t)??null}get activeAssociationsInput(){return this._activeAssociationsInput}get calculating(){return this._expressionsManager.calculating}get expressionsManager(){return this._expressionsManager}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:t}=this;return this.invalidFeatures.some(e=>e!==t)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){const t=this.contingentValuesManager;for(const e of this.layers)if(t.getFieldsWithContingentValues(e).size>0)return!0;return!1}get visibleInputs(){return this.activeForm.inputs.filter(t=>t.visible)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return"noElements";const t=new Set;for(const e of this.activeForm.inputs)switch(e.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":t.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":t.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return t.has("allElementsHidden")?"allElementsHidden":"noElementsInCommon"}get page(){return this.selectedAttachmentDetails?"viewing-attachment-details":this.selectedAttachmentAddInput?"adding-attachments":this.selectedAttachmentListInput?"viewing-attachments":this.activeAssociationsInput?.associatedLayer?"viewing-associated-features":this.activeAssociationsInput?"viewing-associated-layers":"default"}get status(){const t=this._prepareTask;return null==t?"not-loaded":t.finished?null!=t.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid&&Array.from(this._featureFormMap.values()).every(t=>t.valid)}get layers(){const t=new Set;return this.features.forEach(e=>{const s=w(e);s&&t.add(s)}),Array.from(t)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}get selectedAttachment(){return this._get("selectedAttachment")??null}set selectedAttachment(t){this._set("selectedAttachment",t),null!=t&&(this.selectedAttachmentAddElementId=null)}get selectedAttachmentAddElementId(){return this._get("selectedAttachmentAddElementId")??null}set selectedAttachmentAddElementId(t){this._set("selectedAttachmentAddElementId",t),null!=t&&(this.selectedAttachment=null,this.selectedAttachmentListElementId=null)}get selectedAttachmentListElementId(){return this._get("selectedAttachmentListElementId")??null}set selectedAttachmentListElementId(t){this._set("selectedAttachmentListElementId",t),null!=t&&(this.selectedAttachment=null,this.selectedAttachmentAddElementId=null)}get selectedAttachmentListInput(){const t=this.selectedAttachmentListElementId,e=this.activeForm;return t&&e&&e.allAttachmentElementInputs.find(e=>e.template.elementId===t)||null}get selectedAttachmentAddInput(){const t=this.selectedAttachmentAddElementId,e=this.activeForm;return t&&e&&e.allAttachmentElementInputs.find(e=>e.template.elementId===t)||null}get selectedAttachmentDetails(){const t=this.selectedAttachment,e=this.activeForm;if(!t||!e)return null;const s=e.allAttachmentElementInputs.find(e=>e.template.elementId===t.elementId);if(!s)return null;const n=s.attachments.findIndex(e=>x(e)===t.attachmentKey);if(-1===n)return null;return{attachment:s.attachments[n],input:s}}findFieldInput(t){if(null==t)return;const e=this._activeFormInputsByElementId;if(e.has(t))return e.get(t);const s=this.activeForm.allFieldInputs.find(e=>e.template.elementId===t);return void 0!==s?(e.set(t,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const t of this.visibleInputs){if(B(t)){const e=t.inputs.find(t=>R(t)&&!t.valid);if(e)return{input:e,groupInput:t}}if(R(t)&&!t.valid)return{input:t}}}getFieldInputValue(t){return this.findFieldInput(t)?.value}getValues(t){const e=this._reactiveGraphicLookup.get(t);if(!e)throw new i("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...e.attributes}}async goBack(){switch(this.page){case"viewing-attachment-details":return void this.setSelectedAttachment(null);case"adding-attachments":return void this.setSelectedAttachmentAddElementId(null);case"viewing-attachments":return void this.setSelectedAttachmentListElementId(null);case"viewing-associated-features":return void this.setActiveAssociationsLayer(null);case"viewing-associated-layers":return void this.setActiveAssociationsInput(null);default:return}}async goHome(){this._syncStateToPage("default")}notifyGeometriesChanged(t){const e=[];for(const s of t){const t=this._reactiveGraphicLookup.get(s);t&&(e.push(t),t.geometry=s.geometry)}this._expressionsManager.runGeometryDependentExpressions(e)}async setFieldInputValue(t,e){const s=new Set(this.invalidFeatures);await t.setValueFromUser(e),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:t.features.toArray().map(t=>t.source),fieldName:t.fieldName,name:"value-change",value:e})}async setValue(t,e){const s=this.findFieldInput(t);if(null==s)throw new i("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${t} because none was found in the active form`);await this.setFieldInputValue(s,e)}async stageAddAttachments(t,e){if(0===e.length)return[];const s=this._findAttachmentInput(t);if(!s)return[];const n=await s.stageAddAttachments(e,this._expressionsManager.arcadeContext);return 0===n.length||(this.userHasChangedValues=!0,this._emitAttachmentsChange(s)),n}stageDeleteAttachment(t,e){const s=this._findAttachmentInput(t);if(!s)return;const n=this._findAttachment(s,e);n&&(s.stageDeleteAttachment(n),this.userHasChangedValues=!0,this._emitAttachmentsChange(s))}stageRenameAttachment(t,e,s){const n=this._findAttachmentInput(t);if(!n)return;const i=this._findAttachment(n,e);i&&0!==s.trim().length&&(n.stageRenameAttachment(i,s.trim()),this.userHasChangedValues=!0,this._emitAttachmentsChange(n))}async stageReplaceAttachment(t,e,s){const n=this._findAttachmentInput(t);if(!n)return;const i=this._findAttachment(n,e);i&&(await n.stageReplaceAttachment(i,s,this._expressionsManager.arcadeContext),this.userHasChangedValues=!0,this._emitAttachmentsChange(n))}clearAttachmentChanges(t){const e=this._findAttachmentInput(t);e&&(e.clearAttachmentChanges(),this._emitAttachmentsChange(e))}setActiveAssociationsInput(t){this._activeAssociationsInput=t}setActiveAssociationsLayer(t){this._activeAssociationsInput?.setAssociatedLayer(t)}setActiveAssociationType(t){this._activeAssociationsInput?.setActiveAssociationType(t)}setSelectedAttachment(t){this.selectedAttachment=t??null}setSelectedAttachmentAddElementId(t){this.selectedAttachmentAddElementId=t??null}setSelectedAttachmentListElementId(t){this.selectedAttachmentListElementId=t??null}_syncStateToPage(t){switch(t){case"viewing-attachment-details":return this.setSelectedAttachmentAddElementId(null),this.setActiveAssociationsLayer(null),void this.setActiveAssociationsInput(null);case"viewing-attachments":return this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setActiveAssociationsLayer(null),void this.setActiveAssociationsInput(null);case"adding-attachments":return this.setSelectedAttachment(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),void this.setActiveAssociationsInput(null);case"viewing-associated-features":return this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),void this.setSelectedAttachmentListElementId(null);case"viewing-associated-layers":return this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),void this.setActiveAssociationsLayer(null);default:return this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),void this.setActiveAssociationsInput(null)}}userChangesHaveMadeFeatureInvalid(t){return!!this._reactiveGraphicLookup.get(t)?.userChangesHaveMadeInvalid}async _trackValidityChange(t){await v(()=>!1===this.calculating);const e=this.invalidFeatures;for(const s of e)!1===t.has(s)&&this._reactiveGraphicLookup.has(s)&&(this._reactiveGraphicLookup.get(s).userChangesHaveMadeInvalid=!0)}validate(){return!1}_makeBatchFormInputsForFeature(t){const e=this._layerTemplateMap.get(t.layer);return e?H(e,{allFeatures:new n([t]),expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}):this._emptyForm}_makeSubmitResults(){const t=new Map;for(const[s,n]of this._reactiveGraphicLookup){const i=[],a=[],r=this._featureFormMap.get(n)?.allAttachmentElementInputs??[];for(const t of r)e(i,t.toSubmitEdits()),t.valid||a.push(t.template.elementId);t.set(s,{feature:s,values:{...n.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:a})}for(const e of this.sharedForm.allFieldInputs)for(const s of e.invalidFeatures)t.get(s)?.invalidFields.push(e.fieldName);return Array.from(t.values())}_findAttachmentInput(t){const e=this.activeForm.allAttachmentElementInputs.find(e=>e.template.elementId===t);return e||r.getLogger(this).error(`Attachment input not found for elementId '${t}'`),e}_findAttachment(t,e){const s=t.findAttachment(e);return s||r.getLogger(this).error(`Attachment '${e}' not found for attachment element '${t.template.elementId}'`),s}_makeAttachmentEdits(t){const s=[];for(const n of t.allAttachmentElementInputs)e(s,n.toSubmitEdits());return s}_emitAttachmentsChange(t){const e=t.single.feature;if(!e)return;const s=this._featureFormMap.get(e);this.emit("attachments-change",{name:"attachments-change",feature:e.source,attachmentEdits:this._makeAttachmentEdits(s??this.activeForm),valid:this.valid})}_prepare(){this._hasAsyncArcadeExpressions=!1,this._prepareTask=c(this._prepareTask),this._updateWorkingFeatures(),l(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new T({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??I.WebMercator,map:this.map,timeZone:this.timeZone||"system"}});const{layers:t}=this;if(0===t.length)return;const e=s(async e=>{try{h(e),this.contingentValuesManager.layers.addMany(t);const s=new Map;await Promise.all(t.map(t=>t.load()));for(const i of t){const t=Z(this.layerInfos,i),n=await G(i,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone},t?.formTemplate);h(e),this._layerTemplateMap.set(i,n);const a=n.getExpressionExecutorsForLayer(i);if(this._expressionsManager.layerExpressionsModelMap.set(i,new S({preserveFieldValuesWhenHidden:n.preserveFieldValuesWhenHidden,executorMap:a})),!this._hasAsyncArcadeExpressions)for(const e of a.keys()){const t=a.get(e);if(this._hasAsyncArcadeExpressions=!0===(t.editableExpression?.isAsync||t.requiredExpression?.isAsync||t.valueExpression?.isAsync||t.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions)break}for(const e of n.elements){if(U(e))continue;const t=e.clone();W(t)&&(t.elements=t.elements.filter(t=>!U(t)));const{elementId:n}=t;s.has(n)?s.get(n).foldIn(t):s.set(n,t)}}if(this.hasTooManyComplexFeatures)throw new i("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new i("too-many-features","There are too many features to load into the form.");const n=new O({elements:Array.from(s.values())});this.sharedFormTemplate=n,this.sharedForm=H(n,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}),await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray()),await v(()=>!this.contingentValuesManager.updating)}catch(s){throw u(s)||r.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.consumePromise(e.promise),this._prepareTask=e}_updateWorkingFeatures(){this._workingFeatures.destroyAll();for(const e of this._featureFormMap.values())e.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();const{features:t}=this;if(this._reactiveGraphicLookup=new m,0!==t.length){this._workingFeatures.addMany(t.map(M));for(const t of this._workingFeatures)this._reactiveGraphicLookup.set(t.source,t)}}async _syncAttachments(){const{activeFeature:t,activeLayer:e,activeForm:s}=this;if(!(t&&s&&C(e)&&k(e)))return;const n=t.getObjectId();if(null==n)return;const i=this._attachmentCache.get(e),a=s.allAttachmentElementInputs;if(!a.length)return;let r;if(i){const t=i.get(n);t&&(r=t)}if(!r){r=await V(e,n,a);o(this._attachmentCache,e,()=>new m).set(n,r)}for(const o of a)o.applyFetchedAttachments(q(o,r))}};t([y()],D.prototype,"_attachmentCache",void 0),t([y({readOnly:!0})],D.prototype,"activeFeature",null),t([y()],D.prototype,"activeFeatureIndex",void 0),t([y({readOnly:!0})],D.prototype,"activeForm",null),t([y({readOnly:!0})],D.prototype,"activeLayer",null),t([y()],D.prototype,"activeAssociationsInput",null),t([y()],D.prototype,"disabled",void 0),t([y()],D.prototype,"calculating",null),t([y()],D.prototype,"contingentValuesManager",void 0),t([y()],D.prototype,"editType",void 0),t([y()],D.prototype,"features",void 0),t([y()],D.prototype,"expressionEvaluationFailed",null),t([y()],D.prototype,"hasNonActiveInvalidFeatures",null),t([y()],D.prototype,"hasAsyncArcadeExpressions",null),t([y()],D.prototype,"_hasAsyncArcadeExpressions",void 0),t([y()],D.prototype,"invalidFeatures",null),t([y()],D.prototype,"hasVisibleInputs",null),t([y()],D.prototype,"hasLayersWithContingentValues",null),t([y()],D.prototype,"maximumFeatureCount",void 0),t([y()],D.prototype,"maximumFeatureCountWithComplexForms",void 0),t([y()],D.prototype,"visibleInputs",null),t([y()],D.prototype,"map",void 0),t([y()],D.prototype,"noVisibleElementsReason",null),t([y()],D.prototype,"page",null),t([y()],D.prototype,"pageStack",void 0),t([y()],D.prototype,"readOnly",void 0),t([y()],D.prototype,"spatialReference",void 0),t([y()],D.prototype,"submitHasBeenAttempted",void 0),t([y()],D.prototype,"timeZone",void 0),t([y()],D.prototype,"updating",null),t([y()],D.prototype,"valid",null),t([y()],D.prototype,"layers",null),t([y()],D.prototype,"mode",null),t([y()],D.prototype,"sharedForm",void 0),t([y()],D.prototype,"sharedFormTemplate",void 0),t([y()],D.prototype,"selectedAttachment",null),t([y()],D.prototype,"selectedAttachmentAddElementId",null),t([y()],D.prototype,"selectedAttachmentListElementId",null),t([y()],D.prototype,"selectedAttachmentListInput",null),t([y()],D.prototype,"selectedAttachmentAddInput",null),t([y()],D.prototype,"selectedAttachmentDetails",null),t([y()],D.prototype,"userHasChangedValues",void 0),t([y()],D.prototype,"layerInfos",void 0),t([y()],D.prototype,"_arcadeExecutorProvider",void 0),t([y()],D.prototype,"_activeAssociationsInput",void 0),t([y()],D.prototype,"_prepareTask",void 0),t([y()],D.prototype,"_reactiveGraphicLookup",void 0),t([y()],D.prototype,"_layerTemplateMap",void 0),t([y()],D.prototype,"_workingFeatures",void 0),t([y()],D.prototype,"_expressionsManager",void 0),D=t([F("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],D);const $=D;function z(t){return null!=t&&t.trim().length>0}function K(t,e){const s=t.keywords;return z(s)&&s.toLowerCase()===e}function q(t,e){const s="attachment"===t.input?.type?t.input.attachmentAssociationType:"exact",n=t.attachmentKeyword;if("any"===s)return e;if("exactOrNone"===s){if(N(n))return e.filter(t=>!z(t.keywords));const t=n.toLowerCase();return e.filter(e=>!z(e.keywords)||K(e,t))}if(N(n))return e;const i=n.toLowerCase();return e.filter(t=>K(t,i))}export{$ as default};
|
|
2
|
+
import{__decorate as t}from"tslib";import{pushIfSome as e}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import n from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as c}from"../../core/maybe.js";import{throwIfAborted as h,isAbortError as u}from"../../core/promiseUtils.js";import m from"../../core/ReactiveMap.js";import{on as d,sync as p,watch as g,syncAndInitial as A,initial as f,whenOnce as y}from"../../core/reactiveUtils.js";import{property as v,subclass as _}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import I from"../../geometry/SpatialReference.js";import{getGraphicLayer as w}from"../../graphic/graphicOriginUtils.js";import{system as E}from"../../time/constants.js";import{getAttachmentKey as x}from"./attachmentUtils.js";import{createReactiveGraphic as M,isAttributeFormSupportedLayerWithAttachments as C,layerSupportsQueryAttachments as b,queryAttachmentsForElements as k}from"./batchAttributeFormUtils.js";import{ReactiveContingentValuesManager as S}from"./ReactiveContingentValuesManager.js";import{ArcadeExecutorProvider as V}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as L}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as T}from"./expressions/ExpressionsModel.js";import H from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as j}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as P,isFieldInput as R}from"./inputs/support/inputUtils.js";import B from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as U}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as O,isGroupElementTemplate as G}from"./templates/support/templateUtils.js";import{ContingentValuesManager as D}from"../support/ContingentValuesManager.js";import{isEmptyValue as W}from"../support/forms/formUtils.js";function N(t,e){return t?.find(t=>t.layer===e)}let Z=class extends i{constructor(t){super(t),this._attachmentCache=new m,this.activeFeatureIndex=-1,this.callbacks=null,this.disabled=!1,this.editType="NA",this.features=new n,this._hasAsyncArcadeExpressions=!1,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.map=null,this.pageStack=[],this.readOnly=!1,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new V,this._activeAssociationsInput=null,this._ownContingentValuesManager=null,this._activeFormInputsByElementId=new Map,this._emptyForm=new H({inputs:[]}),this._emptyFormTemplate=new B({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new m,this._updatingHandles=new F,this._submitTask=null,this._layerTemplateMap=new m,this._workingFeatures=new n,this._expressionsManager=new L({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:E}}),this._getFieldValueOptionsForFeature=t=>this._reactiveContingentValuesManager.getAndWatchFieldValueOptions(t),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.contingentValuesManager||(this.contingentValuesManager=this._ownContingentValuesManager=new D),this.addHandles([d(()=>this.features,"after-changes",()=>{this.goHome(),this.notifyChange("layers"),this._prepare()},p),g(()=>[this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),p),g(()=>this.activeForm,()=>{this.goHome(),this._activeFormInputsByElementId.clear(),this._syncAttachments()},p),g(()=>this.activeFeature,()=>{this.goHome()},p),g(()=>this.page,t=>{const e=[...this.pageStack];if(e.includes(t))for(;e.length&&e.at(-1)!==t;)e.pop();else e.push(t);this.pageStack=e},A),g(()=>this.contingentValuesManager,t=>{l(this._reactiveContingentValuesManager),this._reactiveContingentValuesManager=new S({manager:t})},f)]),this._prepare()}destroy(){this._prepareTask=c(this._prepareTask),this._workingFeatures.destroyAll(),l(this._expressionsManager),l(this._reactiveContingentValuesManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new m,this._emptyForm.destroy(),this._emptyFormTemplate.destroy(),this._ownContingentValuesManager=l(this._ownContingentValuesManager)}get activeFeature(){const t=this.activeFeatureIndex;return t<0?null:this.features.at(t)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const t=this._workingFeatures.at(this.activeFeatureIndex);if(!t)return this._emptyForm;const e=this._featureFormMap.get(t);if(e)return e;const s=this._makeBatchFormInputsForFeature(t);return s!==this._emptyForm&&this._featureFormMap.set(t,s),s}get activeLayer(){const{activeFeature:t}=this;if(!t)return null;return w(t)??null}get activeAssociationsInput(){return this._activeAssociationsInput}get calculating(){return this._expressionsManager.calculating}get expressionsManager(){return this._expressionsManager}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:t}=this;return this.invalidFeatures.some(e=>e!==t)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){const t=this.contingentValuesManager;for(const e of this.layers)if(t.getFieldsWithContingentValues(e).size>0)return!0;return!1}get visibleInputs(){return this.activeForm.inputs.filter(t=>t.visible)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return"noElements";const t=new Set;for(const e of this.activeForm.inputs)switch(e.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":t.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":t.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return t.has("allElementsHidden")?"allElementsHidden":"noElementsInCommon"}get page(){return this.showingSelectedAttachmentReplacePage&&this.selectedAttachmentDetails?"replacing-attachment":this.selectedAttachmentDetails?"viewing-attachment-details":this.selectedAttachmentAddInput?"adding-attachments":this.selectedAttachmentListInput?"viewing-attachments":this.activeAssociationsInput?.associatedLayer?"viewing-associated-features":this.activeAssociationsInput?"viewing-associated-layers":"default"}get status(){const t=this._prepareTask;return null==t?"not-loaded":t.finished?null!=t.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating||this._hasPendingAttachmentHydration}get valid(){return this.sharedForm.valid&&Array.from(this._featureFormMap.values()).every(t=>t.valid)}get layers(){const t=new Set;return this.features.forEach(e=>{const s=w(e);s&&t.add(s)}),Array.from(t)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){if(this.submitHasBeenAttempted=!0,!this._hasPendingAttachmentHydration)return this._emitSubmit(),Promise.resolve();if(this._submitTask)return this._submitTask.promise;const t=s(async()=>{await Promise.all(this._allAttachmentInputs.map(t=>t.waitForPendingAttachmentUpdateData())),this._emitSubmit()});return this._submitTask=t,t.promise.finally(()=>{this._submitTask===t&&(this._submitTask=null)}),t.promise}get selectedAttachment(){return this._get("selectedAttachment")??null}set selectedAttachment(t){this.showingSelectedAttachmentReplacePage=!1,this._set("selectedAttachment",t),null!=t&&(this.selectedAttachmentAddElementId=null)}get selectedAttachmentAddElementId(){return this._get("selectedAttachmentAddElementId")??null}set selectedAttachmentAddElementId(t){this.showingSelectedAttachmentReplacePage=!1,this._set("selectedAttachmentAddElementId",t),null!=t&&(this.selectedAttachment=null,this.selectedAttachmentListElementId=null)}get selectedAttachmentListElementId(){return this._get("selectedAttachmentListElementId")??null}set selectedAttachmentListElementId(t){this._set("selectedAttachmentListElementId",t),null!=t&&(this.selectedAttachment=null,this.selectedAttachmentAddElementId=null)}get selectedAttachmentListInput(){const t=this.selectedAttachmentListElementId,e=this.activeForm;return t&&e&&e.allAttachmentElementInputs.find(e=>e.template.elementId===t)||null}get showingSelectedAttachmentReplacePage(){return this._get("showingSelectedAttachmentReplacePage")??!1}set showingSelectedAttachmentReplacePage(t){this._set("showingSelectedAttachmentReplacePage",t&&null!=this.selectedAttachmentDetails)}get selectedAttachmentAddInput(){const t=this.selectedAttachmentAddElementId,e=this.activeForm;return t&&e&&e.allAttachmentElementInputs.find(e=>e.template.elementId===t)||null}get selectedAttachmentDetails(){const t=this.selectedAttachment,e=this.activeForm;if(!t||!e)return null;const s=e.allAttachmentElementInputs.find(e=>e.template.elementId===t.elementId);if(!s)return null;const n=s.attachments.findIndex(e=>x(e)===t.attachmentKey);if(-1===n)return null;return{attachment:s.attachments[n],input:s}}get _allAttachmentInputs(){const t=[...this.sharedForm.allAttachmentElementInputs];for(const e of this._featureFormMap.values())t.push(...e.allAttachmentElementInputs);return t}get _hasPendingAttachmentHydration(){return this._allAttachmentInputs.some(t=>t.hasPendingAttachmentUpdateData)}findFieldInput(t){if(null==t)return;const e=this._activeFormInputsByElementId;if(e.has(t))return e.get(t);const s=this.activeForm.allFieldInputs.find(e=>e.template.elementId===t);return void 0!==s?(e.set(t,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const t of this.visibleInputs){if(P(t)){const e=t.inputs.find(t=>R(t)&&!t.valid);if(e)return{input:e,groupInput:t}}if(R(t)&&!t.valid)return{input:t}}}getFieldInputValue(t){return this.findFieldInput(t)?.value}getValues(t){const e=this._reactiveGraphicLookup.get(t);if(!e)throw new a("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...e.attributes}}async goBack(){switch(this.page){case"replacing-attachment":return void this.setShowingSelectedAttachmentReplacePage(!1);case"viewing-attachment-details":return void this.setSelectedAttachment(null);case"adding-attachments":return void this.setSelectedAttachmentAddElementId(null);case"viewing-attachments":return void this.setSelectedAttachmentListElementId(null);case"viewing-associated-features":return void this.setActiveAssociationsLayer(null);case"viewing-associated-layers":return void this.setActiveAssociationsInput(null);default:return}}async goHome(){this._syncStateToPage("default")}notifyGeometriesChanged(t){const e=[];for(const s of t){const t=this._reactiveGraphicLookup.get(s);t&&(e.push(t),t.geometry=s.geometry)}this._expressionsManager.runGeometryDependentExpressions(e)}async setFieldInputValue(t,e){const s=new Set(this.invalidFeatures);await t.setValueFromUser(e),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:t.features.toArray().map(t=>t.source),fieldName:t.fieldName,name:"value-change",value:e})}async setValue(t,e){const s=this.findFieldInput(t);if(null==s)throw new a("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${t} because none was found in the active form`);await this.setFieldInputValue(s,e)}async stageAddAttachments(t,e){if(0===e.length)return[];const s=this._findAttachmentInput(t);if(!s)return[];const n=await s.stageAddAttachments(e,this._expressionsManager.arcadeContext);return 0===n.length||(this.userHasChangedValues=!0,this._emitAttachmentsChange(s)),n}stageDeleteAttachment(t,e){const s=this._findAttachmentInput(t);if(!s)return;const n=this._findAttachment(s,e);n&&(s.stageDeleteAttachment(n),this.userHasChangedValues=!0,this._emitAttachmentsChange(s))}async stageRenameAttachment(t,e,s){const n=this._findAttachmentInput(t);if(!n)return;const a=this._findAttachment(n,e);a&&0!==s.trim().length&&(n.stageRenameAttachment(a,s.trim()),this.userHasChangedValues=!0,await n.ensureStagedUpdateData(a),this._emitAttachmentsChange(n))}async stageReplaceAttachment(t,e,s){const n=this._findAttachmentInput(t);if(!n)return;const a=this._findAttachment(n,e);if(!a)return;await n.stageReplaceAttachment(a,s,this._expressionsManager.arcadeContext)&&(this.userHasChangedValues=!0,this._emitAttachmentsChange(n))}clearAttachmentChanges(t){const e=this._findAttachmentInput(t);e&&(e.clearAttachmentChanges(),this._emitAttachmentsChange(e))}setActiveAssociationsInput(t){this._activeAssociationsInput=t}setActiveAssociationsLayer(t){this._activeAssociationsInput?.setAssociatedLayer(t)}setActiveAssociationType(t){this._activeAssociationsInput?.setActiveAssociationType(t)}resetAttachmentChanges(t,e){const s=this._findAttachmentInput(t);if(!s)return;const n=this._findAttachment(s,e);n&&(s.discardStagedEdits(n),this._emitAttachmentsChange(s))}setSelectedAttachment(t){this.selectedAttachment=t??null}setShowingSelectedAttachmentReplacePage(t){this.showingSelectedAttachmentReplacePage=t}setSelectedAttachmentAddElementId(t){this.selectedAttachmentAddElementId=t??null}setSelectedAttachmentListElementId(t){this.selectedAttachmentListElementId=t??null}_syncStateToPage(t){switch(t){case"replacing-attachment":case"viewing-attachment-details":return this.setSelectedAttachmentAddElementId(null),this.setActiveAssociationsLayer(null),void this.setActiveAssociationsInput(null);case"viewing-attachments":return this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setActiveAssociationsLayer(null),void this.setActiveAssociationsInput(null);case"adding-attachments":return this.setSelectedAttachment(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),void this.setActiveAssociationsInput(null);case"viewing-associated-features":return this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),void this.setSelectedAttachmentListElementId(null);case"viewing-associated-layers":return this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),void this.setActiveAssociationsLayer(null);default:return this.setShowingSelectedAttachmentReplacePage(!1),this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),void this.setActiveAssociationsInput(null)}}userChangesHaveMadeFeatureInvalid(t){return!!this._reactiveGraphicLookup.get(t)?.userChangesHaveMadeInvalid}async _trackValidityChange(t){await y(()=>!1===this.calculating);const e=this.invalidFeatures;for(const s of e)!1===t.has(s)&&this._reactiveGraphicLookup.has(s)&&(this._reactiveGraphicLookup.get(s).userChangesHaveMadeInvalid=!0)}validate(){return!1}_makeBatchFormInputsForFeature(t){const e=this._layerTemplateMap.get(t.layer);return e?j(e,{allFeatures:new n([t]),expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}):this._emptyForm}_makeSubmitResults(){const t=new Map;for(const[s,n]of this._reactiveGraphicLookup){const a=[],i=[],r=this._featureFormMap.get(n)?.allAttachmentElementInputs??[];for(const t of r)e(a,t.toSubmitEdits()),t.valid||i.push(t.template.elementId);t.set(s,{feature:s,values:{...n.attributes},invalidFields:[],attachmentEdits:a,invalidAttachmentElementIds:i})}for(const e of this.sharedForm.allFieldInputs)for(const s of e.invalidFeatures)t.get(s)?.invalidFields.push(e.fieldName);return Array.from(t.values())}_emitSubmit(){this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}_findAttachmentInput(t){const e=this.activeForm.allAttachmentElementInputs.find(e=>e.template.elementId===t);return e||r.getLogger(this).error(`Attachment input not found for elementId '${t}'`),e}_findAttachment(t,e){const s=t.findAttachment(e);return s||r.getLogger(this).error(`Attachment '${e}' not found for attachment element '${t.template.elementId}'`),s}_makeAttachmentEdits(t){const s=[];for(const n of t.allAttachmentElementInputs)e(s,n.toSubmitEdits());return s}_emitAttachmentsChange(t){const e=t.single.feature;if(!e)return;const s=this._featureFormMap.get(e);this.emit("attachments-change",{name:"attachments-change",feature:e.source,attachmentEdits:this._makeAttachmentEdits(s??this.activeForm),valid:this.valid})}_prepare(){this._hasAsyncArcadeExpressions=!1,this._prepareTask=c(this._prepareTask),this._updateWorkingFeatures(),l(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new L({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??I.WebMercator,map:this.map,timeZone:this.timeZone||"system"}});const{layers:t}=this;if(0===t.length)return;const e=s(async e=>{try{h(e),this.contingentValuesManager.layers.addMany(t);const s=new Map;await Promise.all(t.map(t=>t.load()));for(const a of t){const t=N(this.layerInfos,a),n=await U(a,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone},t?.formTemplate);h(e),this._layerTemplateMap.set(a,n);const i=n.getExpressionExecutorsForLayer(a);if(this._expressionsManager.layerExpressionsModelMap.set(a,new T({preserveFieldValuesWhenHidden:n.preserveFieldValuesWhenHidden,executorMap:i})),!this._hasAsyncArcadeExpressions)for(const e of i.keys()){const t=i.get(e);if(this._hasAsyncArcadeExpressions=!0===(t.editableExpression?.isAsync||t.requiredExpression?.isAsync||t.valueExpression?.isAsync||t.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions)break}for(const e of n.elements){if(O(e))continue;const t=e.clone();G(t)&&(t.elements=t.elements.filter(t=>!O(t)));const{elementId:n}=t;s.has(n)?s.get(n).foldIn(t):s.set(n,t)}}if(this.hasTooManyComplexFeatures)throw new a("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new a("too-many-features","There are too many features to load into the form.");const n=new B({elements:Array.from(s.values())});this.sharedFormTemplate=n,this.sharedForm=j(n,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}),await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray()),await y(()=>!this.contingentValuesManager.updating)}catch(s){throw u(s)||r.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.consumePromise(e.promise),this._prepareTask=e}_updateWorkingFeatures(){this._workingFeatures.destroyAll();for(const e of this._featureFormMap.values())e.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();const{features:t}=this;if(this._reactiveGraphicLookup=new m,0!==t.length){this._workingFeatures.addMany(t.map(M));for(const t of this._workingFeatures)this._reactiveGraphicLookup.set(t.source,t)}}async _syncAttachments(){const{activeFeature:t,activeLayer:e,activeForm:s}=this;if(!(t&&s&&C(e)&&b(e)))return;const n=t.getObjectId();if(null==n)return;const a=this._attachmentCache.get(e),i=s.allAttachmentElementInputs;if(!i.length)return;let r;if(a){const t=a.get(n);t&&(r=t)}if(!r){r=await k(e,n,i);o(this._attachmentCache,e,()=>new m).set(n,r)}for(const o of i)o.applyFetchedAttachments(q(o,r))}};t([v()],Z.prototype,"_attachmentCache",void 0),t([v({readOnly:!0})],Z.prototype,"activeFeature",null),t([v()],Z.prototype,"activeFeatureIndex",void 0),t([v({readOnly:!0})],Z.prototype,"activeForm",null),t([v({readOnly:!0})],Z.prototype,"activeLayer",null),t([v()],Z.prototype,"activeAssociationsInput",null),t([v()],Z.prototype,"callbacks",void 0),t([v()],Z.prototype,"disabled",void 0),t([v()],Z.prototype,"calculating",null),t([v()],Z.prototype,"contingentValuesManager",void 0),t([v()],Z.prototype,"editType",void 0),t([v()],Z.prototype,"features",void 0),t([v()],Z.prototype,"expressionEvaluationFailed",null),t([v()],Z.prototype,"hasNonActiveInvalidFeatures",null),t([v()],Z.prototype,"hasAsyncArcadeExpressions",null),t([v()],Z.prototype,"_hasAsyncArcadeExpressions",void 0),t([v()],Z.prototype,"invalidFeatures",null),t([v()],Z.prototype,"hasVisibleInputs",null),t([v()],Z.prototype,"hasLayersWithContingentValues",null),t([v()],Z.prototype,"maximumFeatureCount",void 0),t([v()],Z.prototype,"maximumFeatureCountWithComplexForms",void 0),t([v()],Z.prototype,"visibleInputs",null),t([v()],Z.prototype,"map",void 0),t([v()],Z.prototype,"noVisibleElementsReason",null),t([v()],Z.prototype,"page",null),t([v()],Z.prototype,"pageStack",void 0),t([v()],Z.prototype,"readOnly",void 0),t([v()],Z.prototype,"spatialReference",void 0),t([v()],Z.prototype,"submitHasBeenAttempted",void 0),t([v()],Z.prototype,"timeZone",void 0),t([v()],Z.prototype,"updating",null),t([v()],Z.prototype,"valid",null),t([v()],Z.prototype,"layers",null),t([v()],Z.prototype,"mode",null),t([v()],Z.prototype,"sharedForm",void 0),t([v()],Z.prototype,"sharedFormTemplate",void 0),t([v()],Z.prototype,"selectedAttachment",null),t([v()],Z.prototype,"selectedAttachmentAddElementId",null),t([v()],Z.prototype,"selectedAttachmentListElementId",null),t([v()],Z.prototype,"selectedAttachmentListInput",null),t([v()],Z.prototype,"showingSelectedAttachmentReplacePage",null),t([v()],Z.prototype,"selectedAttachmentAddInput",null),t([v()],Z.prototype,"selectedAttachmentDetails",null),t([v()],Z.prototype,"userHasChangedValues",void 0),t([v()],Z.prototype,"layerInfos",void 0),t([v()],Z.prototype,"_arcadeExecutorProvider",void 0),t([v()],Z.prototype,"_activeAssociationsInput",void 0),t([v()],Z.prototype,"_prepareTask",void 0),t([v()],Z.prototype,"_reactiveGraphicLookup",void 0),t([v()],Z.prototype,"_allAttachmentInputs",null),t([v()],Z.prototype,"_hasPendingAttachmentHydration",null),t([v()],Z.prototype,"_layerTemplateMap",void 0),t([v()],Z.prototype,"_workingFeatures",void 0),t([v()],Z.prototype,"_expressionsManager",void 0),Z=t([_("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],Z);const $=Z;function z(t){return null!=t&&t.trim().length>0}function K(t,e){const s=t.keywords;return z(s)&&s.toLowerCase()===e}function q(t,e){const s="attachment"===t.input?.type?t.input.attachmentAssociationType:"exact",n=t.attachmentKeyword;if("any"===s)return e;if("exactOrNone"===s){if(W(n))return e.filter(t=>!z(t.keywords));const t=n.toLowerCase();return e.filter(e=>!z(e.keywords)||K(e,t))}if(W(n))return e;const a=n.toLowerCase();return e.filter(t=>K(t,a))}export{$ as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
const t="esri-batch-attribute-form",e=`${t}__group`,a=`${t}__input`,n=`${t}__attachment-element`,i=`${t}__multiple-choice-input`,l={base:t,form:`${t}__form`,formHeader:`${t}__form-header`,noticeError:`${t}__notice-error`,label:`${t}__label`,labelTextContent:`${t}__label-text-content`,fieldInput:`${a}`,inputRadio:`${a}--radio`,placeholderRadio:`${a}--radio-placeholder`,inputRadioGroup:`${a}--radio-group`,inputRadioLabel:`${a}--radio-label`,inputDisabled:`${a}--disabled`,inputSwitch:`${a}--switch`,dateInputContainer:`${`${t}__date`}-input-container`,textElementInput:`${t}__text-element-input`,attachmentElementInput:`${n}-input`,attachmentElementLabel:`${n}-label`,attachmentElementList:`${n}-list`,attachmentElementListItem:`${n}-list-item`,attachmentElementListItemStart:`${n}-list-item-start`,attachmentElementListItemStagedIndicator:`${n}-list-item-staged-indicator`,attachmentElementListItemThumb:`${n}-list-item-thumb`,attachmentElementListItemIcon:`${n}-list-item-icon`,attachmentElementEmptyState:`${n}-empty-state`,attachmentElementEmptyAction:`${n}-empty-action`,attachmentElementAllPanel:`${n}-all-panel`,attachmentElementAddPanel:`${n}-add-panel`,attachmentElementFileInput:`${n}-file-input`,attachmentElementAddDropzone:`${n}-add-dropzone`,attachmentElementAddDropzoneIcon:`${n}-add-dropzone-icon`,attachmentElementAddDropzoneHeading:`${n}-add-dropzone-heading`,attachmentElementAddDropzoneDetail:`${n}-add-dropzone-detail`,attachmentElementDetail:`${n}-detail`,attachmentElementDetailPreview:`${n}-detail-preview`,attachmentElementDetailPreviewImage:`${n}-detail-preview-image`,attachmentElementDetailPreviewIcon:`${n}-detail-preview-icon`,attachmentElementDetailActions:`${n}-detail-actions`,attachmentElementDetailMetadata:`${n}-detail-metadata`,attachmentElementDetailMetadataLabel:`${n}-detail-metadata-label`,attachmentElementDetailMetadataValue:`${n}-detail-metadata-value`,relationshipElementInput:`${t}__relationship-element-input`,utilityNetworkAssociationsElementInput:`${t}__utility-network-associations-element-input`,centeredButton:`${t}__centered-button`,description:`${t}__description-text`,block:`${t}__block`,group:e,groupSequential:`${e}--sequential`,individualElement:`${e}__individual-element`,multipleChoiceInput:`${i}`,multipleChoiceSelectAll:`${i}__select-all`,multipleChoiceOtherChoice:`${i}__other-choice`,multipleChoiceOtherChoiceWithSelectAll:`${i}__other-choice--with-select-all`};export{l as css};
|
|
2
|
+
const t="esri-batch-attribute-form",e=`${t}__group`,a=`${t}__input`,n=`${t}__attachment-element`,i=`${t}__multiple-choice-input`,l={base:t,form:`${t}__form`,formHeader:`${t}__form-header`,noticeError:`${t}__notice-error`,label:`${t}__label`,labelTextContent:`${t}__label-text-content`,fieldInput:`${a}`,inputRadio:`${a}--radio`,placeholderRadio:`${a}--radio-placeholder`,inputRadioGroup:`${a}--radio-group`,inputRadioLabel:`${a}--radio-label`,inputDisabled:`${a}--disabled`,inputSwitch:`${a}--switch`,dateInputContainer:`${`${t}__date`}-input-container`,textElementInput:`${t}__text-element-input`,attachmentElementInput:`${n}-input`,attachmentElementLabel:`${n}-label`,attachmentElementList:`${n}-list`,attachmentElementListItem:`${n}-list-item`,attachmentElementListItemStart:`${n}-list-item-start`,attachmentElementListItemStagedIndicator:`${n}-list-item-staged-indicator`,attachmentElementListItemThumb:`${n}-list-item-thumb`,attachmentElementListItemIcon:`${n}-list-item-icon`,attachmentElementEmptyState:`${n}-empty-state`,attachmentElementEmptyAction:`${n}-empty-action`,attachmentElementAllPanel:`${n}-all-panel`,attachmentElementAddPanel:`${n}-add-panel`,attachmentElementFileInput:`${n}-file-input`,attachmentElementAddDropzone:`${n}-add-dropzone`,attachmentElementAddDropzoneIcon:`${n}-add-dropzone-icon`,attachmentElementAddDropzoneHeading:`${n}-add-dropzone-heading`,attachmentElementAddDropzoneDetail:`${n}-add-dropzone-detail`,attachmentElementDetail:`${n}-detail`,attachmentElementDetailPreview:`${n}-detail-preview`,attachmentElementDetailPreviewImage:`${n}-detail-preview-image`,attachmentElementDetailPreviewIcon:`${n}-detail-preview-icon`,attachmentElementDetailActions:`${n}-detail-actions`,attachmentElementDetailMetadata:`${n}-detail-metadata`,attachmentElementDetailMetadataGroup:`${n}-detail-metadata-group`,attachmentElementDetailFileNameRow:`${n}-detail-file-name-row`,attachmentElementDetailFileNameInput:`${n}-detail-file-name-input`,attachmentElementDetailMetadataLabel:`${n}-detail-metadata-label`,attachmentElementDetailMetadataValue:`${n}-detail-metadata-value`,relationshipElementInput:`${t}__relationship-element-input`,utilityNetworkAssociationsElementInput:`${t}__utility-network-associations-element-input`,centeredButton:`${t}__centered-button`,description:`${t}__description-text`,block:`${t}__block`,group:e,groupSequential:`${e}--sequential`,individualElement:`${e}__individual-element`,multipleChoiceInput:`${i}`,multipleChoiceSelectAll:`${i}__select-all`,multipleChoiceOtherChoice:`${i}__other-choice`,multipleChoiceOtherChoiceWithSelectAll:`${i}__other-choice--with-select-all`};export{l as css};
|
|
@@ -88,11 +88,33 @@ export default class AttachmentElementInput extends EditableInput<any> {
|
|
|
88
88
|
applyFetchedAttachments(attachments: AttachmentInfo[]): void;
|
|
89
89
|
/** @internal */
|
|
90
90
|
clearAttachmentChanges(): void;
|
|
91
|
+
/**
|
|
92
|
+
* @param attachment - Attachment whose staged changes should be cleared.
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
discardStagedEdits(attachment: AttachmentInfo): void;
|
|
96
|
+
/**
|
|
97
|
+
* @param attachment - Attachment whose staged update data should be hydrated when needed.
|
|
98
|
+
* @returns `true` when staged update data was hydrated for the attachment.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
ensureStagedUpdateData(attachment: AttachmentInfo): Promise<boolean>;
|
|
91
102
|
/**
|
|
92
103
|
* @param attachmentGlobalId - Global identifier of the attachment to retrieve.
|
|
93
104
|
* @internal
|
|
94
105
|
*/
|
|
95
106
|
findAttachment(attachmentGlobalId: string): AttachmentInfo | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* @param attachment - Attachment whose staged edit state should be resolved.
|
|
109
|
+
* @returns The current staged edit state for the provided attachment.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
getAttachmentEditState(attachment: AttachmentInfo): {
|
|
113
|
+
initialName: string | null;
|
|
114
|
+
isDeleted: boolean;
|
|
115
|
+
isRenamed: boolean;
|
|
116
|
+
isReplaced: boolean;
|
|
117
|
+
};
|
|
96
118
|
/**
|
|
97
119
|
* @param attachment - Attachment whose preview URL should be resolved.
|
|
98
120
|
* @param thumbnailSize - Optional thumbnail width to request for committed service-backed attachments.
|
|
@@ -144,7 +166,9 @@ export default class AttachmentElementInput extends EditableInput<any> {
|
|
|
144
166
|
* @param arcadeContextInfo - Context information used for filename expression evaluation.
|
|
145
167
|
* @internal
|
|
146
168
|
*/
|
|
147
|
-
stageReplaceAttachment(attachment: AttachmentInfo, file: Blob | File, arcadeContextInfo: ArcadeBatchFormCalculationContextInfo): Promise<
|
|
169
|
+
stageReplaceAttachment(attachment: AttachmentInfo, file: Blob | File, arcadeContextInfo: ArcadeBatchFormCalculationContextInfo): Promise<boolean>;
|
|
148
170
|
/** @internal */
|
|
149
171
|
toSubmitEdits(): PendingAttachmentEdits | null;
|
|
172
|
+
/** @internal */
|
|
173
|
+
waitForPendingAttachmentUpdateData(): Promise<void>;
|
|
150
174
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../core/Collection.js";import a from"../../../core/Logger.js";import{isAbortError as s}from"../../../core/promiseUtils.js";import n from"../../../core/ReactiveMap.js";import r from"../../../core/ReactiveSet.js";import{generateBracedUUID as i}from"../../../core/uuid.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{getEffectiveLayerCapabilities as c}from"../../../layers/support/layerUtils.js";import h from"../../../rest/query/support/AttachmentInfo.js";import{getAttachmentTypeCategory as m}from"../../Attachments/support/attachmentUtils.js";import{getAttachmentUrl as d}from"../attachmentUtils.js";import{isAttributeFormSupportedLayer as p}from"../batchAttributeFormUtils.js";import u from"./EditableInput.js";import g from"./SingleFeatureInputAdapter.js";let y=-1,f=class extends u{constructor(t){super(t),this.attachments=[],this.displayCount=3,this.group=null,this.single=new g({input:this}),this.type="attachment",this._initialAttachments=[],this._stagedAdds=new e,this._stagedDeletes=new r,this._stagedUpdates=new n,this._temporaryAttachmentUrls=new n}get allowUserRename(){return this.template.allowUserRename}get addDisabled(){const t=this.maxAttachmentCount;return null!=t&&this.attachments.length>=t}get accept(){const{categories:t}=this;if(!t.size)return;const e=[];return t.has("image")&&e.push("image/*"),t.has("audio")&&e.push("audio/*"),t.has("video")&&e.push("video/*"),t.has("document")&&e.push("text/*","application/*","model/*"),e.length>0?e.join(","):void 0}get categories(){const{input:t}=this,e=new Set;if(!t)return e;if("attachment"===t.type){const{inputTypes:a}=t;if(!a||0===a.length)return e;for(const t of a)_(e,t.type);return e}return _(e,t.type),e}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get allAttachmentsVisibleOnDefaultPage(){return this.defaultPageAttachments.length===this.attachments.length}get defaultPageAttachments(){return this.attachments.slice(0,this.displayCount)}get feature(){return this.single.feature}get hasAttachmentChanges(){return this._stagedAdds.length>0||this._stagedUpdates.size>0||this._stagedDeletes.size>0}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get supportsResize(){const{layer:t}=this;if(!t)return!1;const e=c(t);return!!e&&("attachment"in e&&!!e.attachment?.supportsResize)}get useOriginalFilename(){return this.template.useOriginalFilename}get valid(){const t=this.attachments.length,e=this.minAttachmentCount??-1/0,a=this.maxAttachmentCount??1/0,s=this.hasAttachmentChanges;return!(t<e||t>a)||!s}get _expressionLayer(){const t=this.layer;if(t)return"scene"===t.type&&"associatedLayer"in t&&null!=t.associatedLayer?t.associatedLayer:"feature"===t.type?t:void 0}destroy(){this._clearTemporaryAttachmentUrls()}applyFetchedAttachments(t){for(const e of t)this._normalizeAttachmentName(e);this._initialAttachments=t,this._recomputeAttachments()}clearAttachmentChanges(){this._clearTemporaryAttachmentUrls(),this._stagedAdds.removeAll(),this._stagedUpdates.clear(),this._stagedDeletes.clear(),this._recomputeAttachments()}stageAddAttachment(t){const{contentType:e,data:a,name:s}=t,n=t.globalId??i(),r=a instanceof Blob?a.size:void 0,o=s.trim(),l=new h({contentType:e??void 0,globalId:n,id:y--,keywords:this.attachmentKeyword??void 0,name:o,size:r});return this._setTemporaryAttachmentUrl(n,a),this._stagedAdds.add({globalId:n,info:l,data:a}),this._recomputeAttachments(),l}async stageAddAttachments(t,e){const a=t.filter(t=>this.isFileAllowed(t));if(0===a.length)return[];const s=[],n=new Map,r=Date.now();for(let i=0;i<a.length;i++){const t=a[i],o=t instanceof File?t.name:`attachment-${r}_${i+1}`,l=await this._computeAttachmentFilename(o,e),c=this._makeUniqueFilenameForOperation(n,l);s.push(this.stageAddAttachment({contentType:t.type,data:t,name:c}))}return s}findAttachment(t){if(t)return this.attachments.find(e=>e.globalId===t)}getAttachmentPreviewUrl(t,e){return(t.globalId?this._temporaryAttachmentUrls.get(t.globalId):void 0)??d(t,this.supportsResize,e)}isFileAllowed(t){if(!t.type)return!0;const{categories:e}=this;return!e.size||e.has(m(t.type))}isStagedAttachmentAddition(t){return"number"==typeof t.id&&t.id<0}stageDeleteAttachment(t){const e=t.globalId;if(!e)return;const a=this._stagedAdds.findIndex(t=>t.globalId===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedUpdates.delete(e),this._stagedDeletes.add(e),this._recomputeAttachments()}stageRenameAttachment(t,e){const a=t.globalId;if(!a)return;const s=this._stagedAdds.find(t=>t.globalId===a);if(s)return s.info.name=e,void this._recomputeAttachments();const n=this._stagedUpdates.get(a);this._stagedUpdates.set(a,{...n,info:t,name:e}),this._recomputeAttachments()}async stageReplaceAttachment(t,e,a){const s=e instanceof File?e.name:t.name,n=await this._computeAttachmentFilename(s,a);this._stageReplaceAttachment(t,e,n)}toSubmitEdits(){const t=[],e=[],s=Array.from(this._stagedDeletes);if(0===this._stagedAdds.length&&0===this._stagedUpdates.size&&0===s.length)return null;const n=this._featureIdentifier;if(!n)return a.getLogger(this).error("Unable to build attachment edits without a valid feature and layer."),null;for(const a of this._stagedAdds)t.push({feature:n,attachment:{globalId:a.globalId,contentType:a.info.contentType,data:a.data,name:a.info.name}});for(const[a,r]of this._stagedUpdates)e.push({feature:n,attachment:{globalId:a,contentType:r.contentType,data:r.data,name:r.name}});return{label:this.template.label,attachmentKeyword:this.attachmentKeyword,add:t,delete:s,update:e}}_recomputeAttachments(){const t=this._stagedDeletes,e=[];for(const a of this._stagedAdds)e.push(a.info);for(const a of this._initialAttachments){const s=a.globalId;if(!s||!t.has(s)){if(s&&this._stagedUpdates.has(s)){const t=this._stagedUpdates.get(s),n=a.clone();null!=t.name&&(n.name=t.name),e.push(n);continue}e.push(a)}}this.attachments=e}get _featureIdentifier(){const t=this.single.feature,e=this.layer;if(!t||!p(e))return null;const a=e.objectIdField,s="globalIdField"in e?e.globalIdField:null,n=t.getGlobalId()??(s?t.getAttribute(s):void 0);if(n)return{globalId:n};const r=t.getObjectId()??t.getAttribute(a),i=Number(r);return null==r||isNaN(i)?null:{objectId:i}}async _computeAttachmentFilename(t,e){const n=this.template.filenameExpressionExecutor;if(!n)return t;const r=this.single.feature,i=r?.plainGraphic,o=this._expressionLayer,l={$originalfeature:r?.original,$editcontext:{editType:e.editType},$layer:o,$featureset:o,$datastore:o?.url,$feature:i,$map:e.map},c={rawOutput:!0,spatialReference:e.spatialReference,timeZone:e.timeZone};try{const t=n.isAsync?await n.executeAsync(l,c):n.execute(l,c);if("string"==typeof t&&t.trim().length>0)return t.trim()}catch(h){s(h)||a.getLogger(this).error("Failed evaluating attachment filename expression",h)}return t}_makeUniqueFilenameForOperation(t,e){const a=e.toLowerCase(),s=t.get(a)??0;if(t.set(a,s+1),0===s)return e;const n=e.lastIndexOf(".");return`${n>0?e.slice(0,n):e}_${s}${n>0?e.slice(n):""}`}_stageReplaceAttachment(t,e,a){const s=t.globalId;if(!s)return;const n=this._stagedAdds.find(t=>t.globalId===s);if(n)return n.data=e,n.info.name=a,n.info.contentType=e.type,n.info.size=e.size,this._setTemporaryAttachmentUrl(s,e),void this._recomputeAttachments();const r=this._stagedUpdates.get(s);this._setTemporaryAttachmentUrl(s,e),this._stagedUpdates.set(s,{...r,info:t,contentType:e.type||r?.contentType,data:e,name:a}),this._recomputeAttachments()}_normalizeAttachmentName(t){const{name:e}=t;"string"==typeof e&&(t.name=e.trim())}_setTemporaryAttachmentUrl(t,e){if(this._clearTemporaryAttachmentUrl(t),!(e instanceof Blob))return;const a=URL.createObjectURL(e);return this._temporaryAttachmentUrls.set(t,a),a}_clearTemporaryAttachmentUrl(t){const e=this._temporaryAttachmentUrls.get(t);e&&(URL.revokeObjectURL(e),this._temporaryAttachmentUrls.delete(t))}_clearTemporaryAttachmentUrls(){for(const t of this._temporaryAttachmentUrls.values())URL.revokeObjectURL(t);this._temporaryAttachmentUrls.clear()}};t([o()],f.prototype,"allowUserRename",null),t([o({readOnly:!0})],f.prototype,"addDisabled",null),t([o({readOnly:!0})],f.prototype,"accept",null),t([o({readOnly:!0})],f.prototype,"categories",null),t([o()],f.prototype,"attachmentKeyword",null),t([o()],f.prototype,"attachments",void 0),t([o()],f.prototype,"displayFilename",null),t([o({readOnly:!0})],f.prototype,"allAttachmentsVisibleOnDefaultPage",null),t([o({readOnly:!0})],f.prototype,"defaultPageAttachments",null),t([o()],f.prototype,"displayCount",void 0),t([o()],f.prototype,"feature",null),t([o()],f.prototype,"group",void 0),t([o({readOnly:!0})],f.prototype,"hasAttachmentChanges",null),t([o()],f.prototype,"input",null),t([o()],f.prototype,"layer",null),t([o()],f.prototype,"maxAttachmentCount",null),t([o()],f.prototype,"minAttachmentCount",null),t([o({readOnly:!0})],f.prototype,"single",void 0),t([o({readOnly:!0})],f.prototype,"type",void 0),t([o({readOnly:!0})],f.prototype,"supportsResize",null),t([o()],f.prototype,"useOriginalFilename",null),t([o({readOnly:!0})],f.prototype,"valid",null),t([o()],f.prototype,"_initialAttachments",void 0),t([o()],f.prototype,"_expressionLayer",null),t([o()],f.prototype,"_stagedAdds",void 0),t([o()],f.prototype,"_stagedDeletes",void 0),t([o()],f.prototype,"_stagedUpdates",void 0),t([o()],f.prototype,"_temporaryAttachmentUrls",void 0),t([o()],f.prototype,"_featureIdentifier",null),f=t([l("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],f);const A=f;function _(t,e){switch(e){case"audio":t.add("audio");break;case"document":t.add("document");break;case"image":case"signature":t.add("image");break;case"video":t.add("video")}}export{A as default};
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../request.js";import a from"../../../core/Collection.js";import n from"../../../core/Logger.js";import{isAbortError as s}from"../../../core/promiseUtils.js";import i from"../../../core/ReactiveMap.js";import r from"../../../core/ReactiveSet.js";import{generateBracedUUID as d}from"../../../core/uuid.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{getEffectiveLayerCapabilities as h}from"../../../layers/support/layerUtils.js";import p from"../../../rest/query/support/AttachmentInfo.js";import{getAttachmentTypeCategory as c}from"../../Attachments/support/attachmentUtils.js";import{getAttachmentUrl as m}from"../attachmentUtils.js";import{isAttributeFormSupportedLayer as g}from"../batchAttributeFormUtils.js";import u from"./EditableInput.js";import y from"./SingleFeatureInputAdapter.js";let f=-1,_=class extends u{constructor(t){super(t),this.attachments=[],this.displayCount=3,this.group=null,this.single=new y({input:this}),this.type="attachment",this._initialAttachments=[],this._stagedAdds=new a,this._stagedDeletes=new r,this._stagedUpdates=new i,this._failedStagedUpdateHydrations=new r,this._pendingStagedUpdateHydrations=new i,this._temporaryAttachmentUrls=new i}get allowUserRename(){return this.template.allowUserRename}get addDisabled(){const t=this.maxAttachmentCount;return null!=t&&this.attachments.length>=t}get accept(){const{categories:t}=this;if(!t.size)return;const e=[];return t.has("image")&&e.push("image/*"),t.has("audio")&&e.push("audio/*"),t.has("video")&&e.push("video/*"),t.has("document")&&e.push("text/*","application/*","model/*"),e.length>0?e.join(","):void 0}get categories(){const{input:t}=this,e=new Set;if(!t)return e;if("attachment"===t.type){const{inputTypes:a}=t;if(!a||0===a.length)return e;for(const t of a)U(e,t.type);return e}return U(e,t.type),e}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get allAttachmentsVisibleOnDefaultPage(){return this.defaultPageAttachments.length===this.attachments.length}get defaultPageAttachments(){return this.attachments.slice(0,this.displayCount)}get feature(){return this.single.feature}get hasAttachmentChanges(){return this._stagedAdds.length>0||this._stagedUpdates.size>0||this._stagedDeletes.size>0}get hasPendingAttachmentUpdateData(){return this._pendingStagedUpdateHydrations.size>0}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get supportsResize(){const{layer:t}=this;if(!t)return!1;const e=h(t);return!!e&&("attachment"in e&&!!e.attachment?.supportsResize)}get useOriginalFilename(){return this.template.useOriginalFilename}get valid(){const t=this.attachments.length,e=this.minAttachmentCount??-1/0,a=this.maxAttachmentCount??1/0,n=this.hasAttachmentChanges;return!(this._failedStagedUpdateHydrations.size>0)&&(!(t<e||t>a)||!n)}get _expressionLayer(){const t=this.layer;if(t)return"scene"===t.type&&"associatedLayer"in t&&null!=t.associatedLayer?t.associatedLayer:"feature"===t.type?t:void 0}destroy(){this._clearTemporaryAttachmentUrls()}applyFetchedAttachments(t){for(const e of t)this._normalizeAttachmentName(e);this._initialAttachments=t,this._failedStagedUpdateHydrations.clear(),this._recomputeAttachments()}clearAttachmentChanges(){this._clearTemporaryAttachmentUrls(),this._stagedAdds.removeAll(),this._stagedUpdates.clear(),this._stagedDeletes.clear(),this._failedStagedUpdateHydrations.clear(),this._pendingStagedUpdateHydrations.clear(),this._recomputeAttachments()}stageAddAttachment(t){const{contentType:e,data:a,name:n}=t,s=t.globalId??d(),i=a instanceof Blob?a.size:void 0,r=n.trim(),o=new p({contentType:e??void 0,globalId:s,id:f--,keywords:this.attachmentKeyword??void 0,name:r,size:i});return this._setTemporaryAttachmentUrl(s,a),this._stagedAdds.add({globalId:s,info:o,data:a}),this._recomputeAttachments(),o}async stageAddAttachments(t,e){const a=t.filter(t=>this.isFileAllowed(t));if(0===a.length)return[];const n=[],s=new Map,i=Date.now();for(let r=0;r<a.length;r++){const t=a[r],d=t instanceof File?t.name:`attachment-${i}_${r+1}`,o=await this._computeAttachmentFilename(d,e),l=this._makeUniqueFilenameForOperation(s,o);n.push(this.stageAddAttachment({contentType:t.type,data:t,name:l}))}return n}findAttachment(t){if(t)return this.attachments.find(e=>e.globalId===t)}getAttachmentEditState(t){const e=t.globalId,a=e?this._getInitialAttachment(e):void 0,n=a?.name??null,s=e?this._stagedUpdates.get(e):void 0,i=s?.name??t.name??null;return{initialName:n,isDeleted:!!e&&this._stagedDeletes.has(e),isRenamed:null!=i&&null!=n&&i!==n,isReplaced:!!s?.data}}getAttachmentPreviewUrl(t,e){return(t.globalId?this._temporaryAttachmentUrls.get(t.globalId):void 0)??m(t,this.supportsResize,e)}async ensureStagedUpdateData(t){const e=t.globalId;if(!e)return!1;const a=this._stagedUpdates.get(e);if(!a||a.data||this._stagedDeletes.has(e))return this._failedStagedUpdateHydrations.delete(e),!1;const n=this._pendingStagedUpdateHydrations.get(e);if(n)return await n;const s=this._hydrateStagedUpdateData(t);this._pendingStagedUpdateHydrations.set(e,s);try{return await s}finally{this._pendingStagedUpdateHydrations.get(e)===s&&this._pendingStagedUpdateHydrations.delete(e)}}async waitForPendingAttachmentUpdateData(){await Promise.allSettled(Array.from(this._pendingStagedUpdateHydrations.values()))}discardStagedEdits(t){const e=t.globalId;if(!e)return;const a=this._stagedAdds.findIndex(t=>t.globalId===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedDeletes.delete(e),this._stagedUpdates.delete(e),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),this._recomputeAttachments()}isFileAllowed(t){if(!t.type)return!0;const{categories:e}=this;return!e.size||e.has(c(t.type))}isStagedAttachmentAddition(t){return"number"==typeof t.id&&t.id<0}stageDeleteAttachment(t){const e=t.globalId;if(!e)return;const a=this._stagedAdds.findIndex(t=>t.globalId===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedUpdates.delete(e),this._stagedDeletes.add(e),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),this._recomputeAttachments()}stageRenameAttachment(t,e){const a=t.globalId;if(!a)return;const n=this._stagedAdds.find(t=>t.globalId===a);if(n)return n.info.name=e,void this._recomputeAttachments();const s=this._stagedUpdates.get(a),i=this._getInitialAttachment(a)?.name??null,r=null!=i&&e===i;if(r&&null==s?.data&&null==s?.contentType&&null==s?.size)return this._stagedUpdates.delete(a),this._failedStagedUpdateHydrations.delete(a),this._pendingStagedUpdateHydrations.delete(a),void this._recomputeAttachments();const d={...s,info:t};r?delete d.name:d.name=e,this._stagedUpdates.set(a,d),this._recomputeAttachments(),this.ensureStagedUpdateData(t)}async stageReplaceAttachment(t,e,a){if(!this.isFileAllowed(e))return!1;const n=e instanceof File?e.name:t.name,s=await this._computeAttachmentFilename(n,a);return this._stageReplaceAttachment(t,e,s),!0}toSubmitEdits(){const t=[],e=[],a=Array.from(this._stagedDeletes);if(0===this._stagedAdds.length&&0===this._stagedUpdates.size&&0===a.length)return null;const s=this._featureIdentifier;if(!s)return n.getLogger(this).error("Unable to build attachment edits without a valid feature and layer."),null;for(const n of this._stagedAdds)t.push({feature:s,attachment:{globalId:n.globalId,contentType:n.info.contentType,data:n.data,name:n.info.name}});for(const[n,i]of this._stagedUpdates)this._canSubmitStagedUpdate(i)&&e.push({feature:s,attachment:{globalId:n,contentType:i.contentType,data:i.data,name:i.name}});return 0===t.length&&0===e.length&&0===a.length?null:{label:this.template.label,attachmentKeyword:this.attachmentKeyword,add:t,delete:a,update:e}}_recomputeAttachments(){const t=this._stagedDeletes,e=[];for(const a of this._stagedAdds)e.push(a.info);for(const a of this._initialAttachments){const n=a.globalId;if(!n||!t.has(n)){if(n&&this._stagedUpdates.has(n)){const t=this._stagedUpdates.get(n),s=a.clone();null!=t.name&&(s.name=t.name),null!=t.contentType&&(s.contentType=t.contentType),null!=t.size&&(s.size=t.size),e.push(s);continue}e.push(a)}}this.attachments=e}get _featureIdentifier(){const t=this.single.feature,e=this.layer;if(!t||!g(e))return null;const a=e.objectIdField,n="globalIdField"in e?e.globalIdField:null,s=t.getGlobalId()??(n?t.getAttribute(n):void 0);if(s)return{globalId:s};const i=t.getObjectId()??t.getAttribute(a),r=Number(i);return null==i||isNaN(r)?null:{objectId:r}}async _computeAttachmentFilename(t,e){const a=this.template.filenameExpressionExecutor;if(!a)return t;const i=this.single.feature,r=i?.plainGraphic,d=this._expressionLayer,o={$originalfeature:i?.original,$editcontext:{editType:e.editType},$layer:d,$featureset:d,$datastore:d?.url,$feature:r,$map:e.map},l={rawOutput:!0,spatialReference:e.spatialReference,timeZone:e.timeZone};try{const t=a.isAsync?await a.executeAsync(o,l):a.execute(o,l);if("string"==typeof t&&t.trim().length>0)return t.trim()}catch(h){s(h)||n.getLogger(this).error("Failed evaluating attachment filename expression",h)}return t}_makeUniqueFilenameForOperation(t,e){const a=e.toLowerCase(),n=t.get(a)??0;if(t.set(a,n+1),0===n)return e;const s=e.lastIndexOf(".");return`${s>0?e.slice(0,s):e}_${n}${s>0?e.slice(s):""}`}_stageReplaceAttachment(t,e,a){const n=t.globalId;if(!n)return;const s=this._stagedAdds.find(t=>t.globalId===n);if(s)return s.data=e,s.info.name=a,s.info.contentType=e.type,s.info.size=e.size,this._setTemporaryAttachmentUrl(n,e),void this._recomputeAttachments();const i=this._stagedUpdates.get(n);this._setTemporaryAttachmentUrl(n,e),this._failedStagedUpdateHydrations.delete(n),this._pendingStagedUpdateHydrations.delete(n),this._stagedUpdates.set(n,{...i,info:t,contentType:e.type||i?.contentType||t.contentType,data:e,name:a,size:e.size}),this._recomputeAttachments()}_getInitialAttachment(t){return this._initialAttachments.find(e=>e.globalId===t)}_canSubmitStagedUpdate(t){return null!=t.data}_normalizeAttachmentName(t){const{name:e}=t;"string"==typeof e&&(t.name=e.trim())}async _hydrateStagedUpdateData(t){const a=t.globalId,i=t.url;if(!a||!i)return!1;try{const{data:n}=await e(i,{responseType:"blob"});this._failedStagedUpdateHydrations.delete(a);const s=this._stagedUpdates.get(a);return!(!s||s.data||this._stagedDeletes.has(a))&&(this._stagedUpdates.set(a,{...s,info:t,contentType:s.contentType??t.contentType??n.type,data:n}),!0)}catch(r){const t=this._stagedUpdates.get(a);return!t||t.data||this._stagedDeletes.has(a)||this._failedStagedUpdateHydrations.add(a),s(r)||n.getLogger(this).error("Failed to fetch attachment data for staged update",r),!1}}_setTemporaryAttachmentUrl(t,e){if(this._clearTemporaryAttachmentUrl(t),!(e instanceof Blob))return;const a=URL.createObjectURL(e);return this._temporaryAttachmentUrls.set(t,a),a}_clearTemporaryAttachmentUrl(t){const e=this._temporaryAttachmentUrls.get(t);e&&(URL.revokeObjectURL(e),this._temporaryAttachmentUrls.delete(t))}_clearTemporaryAttachmentUrls(){for(const t of this._temporaryAttachmentUrls.values())URL.revokeObjectURL(t);this._temporaryAttachmentUrls.clear()}};t([o()],_.prototype,"allowUserRename",null),t([o({readOnly:!0})],_.prototype,"addDisabled",null),t([o({readOnly:!0})],_.prototype,"accept",null),t([o({readOnly:!0})],_.prototype,"categories",null),t([o()],_.prototype,"attachmentKeyword",null),t([o()],_.prototype,"attachments",void 0),t([o()],_.prototype,"displayFilename",null),t([o({readOnly:!0})],_.prototype,"allAttachmentsVisibleOnDefaultPage",null),t([o({readOnly:!0})],_.prototype,"defaultPageAttachments",null),t([o()],_.prototype,"displayCount",void 0),t([o()],_.prototype,"feature",null),t([o()],_.prototype,"group",void 0),t([o({readOnly:!0})],_.prototype,"hasAttachmentChanges",null),t([o({readOnly:!0})],_.prototype,"hasPendingAttachmentUpdateData",null),t([o()],_.prototype,"input",null),t([o()],_.prototype,"layer",null),t([o()],_.prototype,"maxAttachmentCount",null),t([o()],_.prototype,"minAttachmentCount",null),t([o({readOnly:!0})],_.prototype,"single",void 0),t([o({readOnly:!0})],_.prototype,"type",void 0),t([o({readOnly:!0})],_.prototype,"supportsResize",null),t([o()],_.prototype,"useOriginalFilename",null),t([o({readOnly:!0})],_.prototype,"valid",null),t([o()],_.prototype,"_initialAttachments",void 0),t([o()],_.prototype,"_expressionLayer",null),t([o()],_.prototype,"_stagedAdds",void 0),t([o()],_.prototype,"_stagedDeletes",void 0),t([o()],_.prototype,"_stagedUpdates",void 0),t([o()],_.prototype,"_failedStagedUpdateHydrations",void 0),t([o()],_.prototype,"_pendingStagedUpdateHydrations",void 0),t([o()],_.prototype,"_temporaryAttachmentUrls",void 0),t([o()],_.prototype,"_featureIdentifier",null),_=t([l("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],_);const A=_;function U(t,e){switch(e){case"audio":t.add("audio");break;case"document":t.add("document");break;case"image":case"signature":t.add("image");break;case"video":t.add("video")}}export{A as default};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type Graphic from "../../../Graphic.js";
|
|
2
|
+
import type RelatedRecordsInfoFieldOrder from "../../../popup/support/RelatedRecordsInfoFieldOrder.js";
|
|
2
3
|
import type EditableInput from "./EditableInput.js";
|
|
3
4
|
import type GroupInput from "./GroupInput.js";
|
|
4
5
|
import type { AttributeFormSupportedLayerUnion } from "../types.js";
|
|
@@ -17,6 +18,26 @@ export interface RelationshipElementInputProperties extends EditableInputPropert
|
|
|
17
18
|
*/
|
|
18
19
|
export default class RelationshipElementInput extends EditableInput<any> {
|
|
19
20
|
constructor(properties: RelationshipElementInputProperties);
|
|
21
|
+
/**
|
|
22
|
+
* A numeric value indicating the maximum number of related features to display in the list of related records.
|
|
23
|
+
* If the total amount of features is greater than the `displayCount`, a `Show all` button displays.
|
|
24
|
+
*
|
|
25
|
+
* @default 3
|
|
26
|
+
* @since 5.1
|
|
27
|
+
*/
|
|
28
|
+
get displayCount(): number;
|
|
29
|
+
/**
|
|
30
|
+
* A string value indicating how to display related records within the relationship content.
|
|
31
|
+
* Currently, `list` is the only supported value.
|
|
32
|
+
*
|
|
33
|
+
* | Value | Description |
|
|
34
|
+
* | ----- | ----------- |
|
|
35
|
+
* | list | Shows a list of related records from the specified relationship. |
|
|
36
|
+
*
|
|
37
|
+
* @default "list"
|
|
38
|
+
* @since 5.1
|
|
39
|
+
*/
|
|
40
|
+
get displayType(): string;
|
|
20
41
|
/**
|
|
21
42
|
* The single feature associated with this relationship element.
|
|
22
43
|
*
|
|
@@ -31,7 +52,8 @@ export default class RelationshipElementInput extends EditableInput<any> {
|
|
|
31
52
|
*/
|
|
32
53
|
get group(): GroupInput | null;
|
|
33
54
|
/**
|
|
34
|
-
* Identifies the single feature layer associated with this relationship element.
|
|
55
|
+
* Identifies the single feature layer associated with this relationship element.
|
|
56
|
+
* The layer must support feature editing and field access.
|
|
35
57
|
*
|
|
36
58
|
* The following layer types are supported:
|
|
37
59
|
* - [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/)
|
|
@@ -45,10 +67,33 @@ export default class RelationshipElementInput extends EditableInput<any> {
|
|
|
45
67
|
* @see [BatchAttributeFormViewModel.layers](https://developers.arcgis.com/javascript/latest/references/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel/#layers)
|
|
46
68
|
*/
|
|
47
69
|
get layer(): AttributeFormSupportedLayerUnion | null | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* An array of [RelatedRecordsInfoFieldOrder](https://developers.arcgis.com/javascript/latest/references/core/popup/support/RelatedRecordsInfoFieldOrder/)
|
|
72
|
+
* objects indicating the field display order for the related records
|
|
73
|
+
* and whether they should be sorted in ascending `asc` or descending `desc` order.
|
|
74
|
+
*
|
|
75
|
+
* @since 5.1
|
|
76
|
+
*/
|
|
77
|
+
get orderByFields(): RelatedRecordsInfoFieldOrder[] | null | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* The numeric id value for the defined relationship.
|
|
80
|
+
* This value can be found on the [service](https://developers.arcgis.com/rest/services-reference/enterprise/feature-service.htm)
|
|
81
|
+
* itself or on the service's [relationships resource](https://developers.arcgis.com/rest/services-reference/enterprise/relationships-feature-service-.htm)
|
|
82
|
+
* if `supportsRelationshipResource` is `true`.
|
|
83
|
+
*
|
|
84
|
+
* @since 5.1
|
|
85
|
+
*/
|
|
86
|
+
get relationshipId(): number;
|
|
48
87
|
/**
|
|
49
88
|
* The type of input.
|
|
50
89
|
*
|
|
51
90
|
* @since 5.1
|
|
52
91
|
*/
|
|
53
92
|
get type(): "relationship";
|
|
93
|
+
/**
|
|
94
|
+
* Indicates whether the form is currently updating.
|
|
95
|
+
*
|
|
96
|
+
* @since 5.1
|
|
97
|
+
*/
|
|
98
|
+
get updating(): boolean;
|
|
54
99
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as
|
|
2
|
+
import{__decorate as e}from"tslib";import{destroyMaybe as t}from"../../../core/maybe.js";import{on as r}from"../../../core/reactiveUtils.js";import{property as l,subclass as i}from"../../../core/accessorSupport/decorators.js";import{isSubtypeGroupLayer as a,getEffectiveLayerCapabilities as o}from"../../../layers/support/layerUtils.js";import{isRelatableFeatureSupportedLayer as s}from"../../../popup/support/featureUtils.js";import n from"./EditableInput.js";import p from"./SingleFeatureInputAdapter.js";import d from"../../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import{getComputedAttributes as u,parseFormTemplateString as h}from"../../FeatureForm/featureFormUtils.js";let y=class extends n{constructor(e){super(e),this._relationshipVM=new d,this.group=null,this.map=null,this.single=new p({input:this}),this.type="relationship"}initialize(){this._setRelationshipVMProps(),this.addHandles([r(()=>this.relatedLayer,"edits",()=>this._relationshipVM?.refresh())])}destroy(){t(this._relationshipVM)}get activeCategory(){return this._relationshipVM.activeCategory}get allCategories(){const{relatedLayer:e,_relationshipVM:t}=this;if(!a(e))return;const r=t?.categories,l=(e.subtypes??[]).map(({code:e,name:t})=>{const l=r?.find(e=>e.name===t);return{name:t,count:l?.count??0,value:l?.value??e}});return l.length?l:null}get categories(){return this.showAllEnabled?this.allCategories:this.allCategories?.slice(0,this.displayCount)}get canAddRelatedFeature(){const{editable:e,relatedFeatureCount:t,relationship:r}=this;if(!r||!this.loaded||!this._relatedLayerAllowsAdds)return!1;if(this.allCategories?.length&&!this.activeCategory)return!1;const{cardinality:l,role:i}=r;return!("one-to-one"===l&&t>0)&&("many-to-many"!==l&&(!("one-to-many"===l&&"destination"===i&&t>0)&&e))}get displayCount(){return this.template.displayCount}get displayType(){return this.template.displayType}get editable(){return!!this._relatedLayerAllowsAdds&&(this._evaluatedEditableExpression??!0)}get feature(){return this.single.feature}get relatedFeatureCount(){return this._relationshipVM?.featureCount??0}get label(){return this.activeCategory?.name?this.activeCategory.name:this.template.label}get layer(){return this.single.layer}get loaded(){return"loading"!==this._relationshipVM?.state}get orderByFields(){return this.template.orderByFields}get originHasValidKey(){return!!this.relationship&&null!=this.feature?.getAttribute(this.relationship.keyField)}get relationship(){return this._relationshipVM?.relationship}get relationshipId(){return this.template.relationshipId}get relatedFeatureInfos(){const{_relationshipVM:e,effectiveTimeZone:t}=this;if(!e?.relatedFeatures?.length||!e?.relatedLayer)return[];const{itemDescriptionFieldName:r,relatedFeatures:l,relatedLayer:i}=e,a=i?.formTemplate?.title||void 0;return l.map(e=>{let l;if(r){const a=e.getAttribute(r),o=i.fieldsIndex.get(r);if(o){const e=u({fields:[o],layer:i,values:[a],timeZone:t})[r];null!=e&&(l=e.toString())}}return{feature:e,description:l,title:a?h({attributes:e.attributes,label:a,layer:i,timeZone:t}):void 0}}).toArray()}get relatedLayer(){return this._relationshipVM?.relatedLayer}get relatedLayerIsTable(){return!!this.relatedLayer?.isTable}get showAllEnabled(){return this._relationshipVM.showAllEnabled}get showAllActionVisible(){return!this.showAllEnabled&&this.relatedFeatureCount>0&&this.relatedFeatureCount>this.displayCount}get showAllCategoriesVisible(){const e=this.allCategories?.length??0;return!this.showAllEnabled&&e>0&&e>this.displayCount}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}setActiveCategory(e){this._relationshipVM.activeCategory=e}setShowAllEnabled(e){this._relationshipVM.showAllEnabled=e}get _relatedLayerAllowsAdds(){const{relatedLayer:e}=this;if(!e||!this._relatedLayerAllowsEdits)return!1;const t=o(e);return!!t?.operations?.supportsAdd}get _relatedLayerAllowsEdits(){const{relatedLayer:e}=this;if(!e)return!1;const t=o(e);return!!t?.operations?.supportsEditing}_setRelationshipVMProps(){const{displayCount:e,feature:t,layer:r,orderByFields:l,map:i,relationshipId:a,showAllEnabled:o}=this;t&&r&&s(r)&&this._relationshipVM.set({displayCount:e,graphic:t.plainGraphic,layer:r,map:i,orderByFields:l,relationshipId:a,showAllEnabled:o})}};e([l()],y.prototype,"_relationshipVM",void 0),e([l()],y.prototype,"activeCategory",null),e([l()],y.prototype,"allCategories",null),e([l()],y.prototype,"categories",null),e([l()],y.prototype,"canAddRelatedFeature",null),e([l()],y.prototype,"displayCount",null),e([l()],y.prototype,"displayType",null),e([l()],y.prototype,"editable",null),e([l()],y.prototype,"feature",null),e([l()],y.prototype,"group",void 0),e([l()],y.prototype,"label",null),e([l()],y.prototype,"layer",null),e([l()],y.prototype,"loaded",null),e([l()],y.prototype,"map",void 0),e([l()],y.prototype,"orderByFields",null),e([l()],y.prototype,"originHasValidKey",null),e([l()],y.prototype,"relationship",null),e([l()],y.prototype,"relationshipId",null),e([l()],y.prototype,"relatedFeatureInfos",null),e([l()],y.prototype,"relatedLayer",null),e([l()],y.prototype,"relatedLayerIsTable",null),e([l({readOnly:!0})],y.prototype,"single",void 0),e([l()],y.prototype,"showAllEnabled",null),e([l()],y.prototype,"showAllActionVisible",null),e([l()],y.prototype,"showAllCategoriesVisible",null),e([l({readOnly:!0})],y.prototype,"type",void 0),e([l()],y.prototype,"updating",null),e([l()],y.prototype,"_relatedLayerAllowsAdds",null),e([l()],y.prototype,"_relatedLayerAllowsEdits",null),y=e([i("esri.widgets.BatchAttributeForm.inputs.RelationshipElementInput")],y);const g=y;export{g as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{ignoreAbortErrors as e}from"../../../core/promiseUtils.js";import{watch as i,sync as o,on as s}from"../../../core/reactiveUtils.js";import{generateUID as r}from"../../../core/uid.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{isAssociationsLayerUnion as n}from"../batchAttributeFormUtils.js";import p from"./EditableInput.js";import u from"./SingleFeatureInputAdapter.js";import d from"../../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";let
|
|
2
|
+
import{__decorate as t}from"tslib";import{ignoreAbortErrors as e}from"../../../core/promiseUtils.js";import{watch as i,sync as o,on as s}from"../../../core/reactiveUtils.js";import{generateUID as r}from"../../../core/uid.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{isAssociationsLayerUnion as n}from"../batchAttributeFormUtils.js";import p from"./EditableInput.js";import u from"./SingleFeatureInputAdapter.js";import d from"../../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";let c=class extends p{constructor(t){super(t),this._associatedLayer=null,this.featureItem=null,this.group=null,this.map=null,this.single=new u({input:this}),this.type="utilityNetworkAssociations",this.viewModel=new d({source:"featureForm"})}initialize(){this.viewModel.set({associationTypes:this.associationTypes,description:this.description,graphic:this.associationFeature,layer:this.associationLayer,map:this.map,title:this.label}),this.addHandles([i(()=>this.associatedLayer,t=>this.showAllAssociatedFeatures(null!=t),o),s(()=>this._editableLayer,"edits",()=>this.refresh())])}get _editableLayer(){const{associatedLayer:t}=this;return"subtype-sublayer"===t?.type?t.parent:t}get activeAssociationType(){return this.viewModel.activeAssociationType}get associatedFeatures(){const{associatedLayer:t}=this;return t?this.associatedFeatureInfos.get(t):void 0}get associatedFeatureInfos(){const{utilityNetwork:t,viewModel:{associationFeatures:e}}=this,i=new Map;return e.size&&t?(e.forEach((t,e)=>{n(e)&&i.set(e,t)}),i):i}get associatedLayer(){return this._associatedLayer}get associationFeature(){return this.feature?.plainGraphic}get associationLayer(){const{layer:t}=this;return n(t)?t:null}get associationTypes(){return this.template.associationTypes}get canAddAssociation(){return!(!this.utilityNetwork||!this.loaded)&&this.editable}get feature(){return this.single.feature}get featureCount(){return this.viewModel.featureCount}get layer(){return this.single.layer}get loaded(){const t=this.viewModel.state;return"loading"!==t&&"disabled"!==t}get showAllEnabled(){return this.viewModel.showAllEnabled}get uid(){return r()}get updating(){const{state:t}=this.viewModel;return"loading"===t||"querying"===t}get utilityNetwork(){return this.viewModel.utilityNetwork}async refresh(){await e(this.viewModel.refresh())}setAssociatedLayer(t){this._associatedLayer=t}setActiveAssociationType(t){this.viewModel.activeAssociationType=t}showAllAssociatedFeatures(t){this.viewModel.showAllEnabled=t}};t([a()],c.prototype,"_associatedLayer",void 0),t([a()],c.prototype,"_editableLayer",null),t([a()],c.prototype,"activeAssociationType",null),t([a()],c.prototype,"associatedFeatures",null),t([a()],c.prototype,"associatedFeatureInfos",null),t([a()],c.prototype,"associatedLayer",null),t([a()],c.prototype,"associationFeature",null),t([a()],c.prototype,"associationLayer",null),t([a()],c.prototype,"associationTypes",null),t([a()],c.prototype,"canAddAssociation",null),t([a()],c.prototype,"feature",null),t([a()],c.prototype,"featureItem",void 0),t([a()],c.prototype,"featureCount",null),t([a()],c.prototype,"group",void 0),t([a()],c.prototype,"layer",null),t([a()],c.prototype,"loaded",null),t([a()],c.prototype,"map",void 0),t([a()],c.prototype,"showAllEnabled",null),t([a({readOnly:!0})],c.prototype,"single",void 0),t([a({readOnly:!0})],c.prototype,"type",void 0),t([a()],c.prototype,"uid",null),t([a()],c.prototype,"updating",null),t([a()],c.prototype,"utilityNetwork",null),t([a()],c.prototype,"viewModel",void 0),c=t([l("esri.widgets.BatchAttributeForm.inputs.UtilityNetworkAssociationsElementInput")],c);const y=c;export{y as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/Error.js";import t from"../AttachmentElementInput.js";import r from"../BatchFormInputs.js";import s from"../FieldInput.js";import n from"../GroupInput.js";import o from"../RelationshipElementInput.js";import a from"../TextElementInput.js";import i from"../UtilityNetworkAssociationsElementInput.js";import{isFieldElementTemplate as l,isGroupElementTemplate as p,isRelationshipElementTemplate as m,isTextElementTemplate as u,isAttachmentElementTemplate as f,isUtilityNetworkAssociationsElementTemplate as c}from"../../templates/support/templateUtils.js";function h(e,t){const s=new r({inputs:e.elements.map(e=>I(e,t)),template:e});return x(s),s}function x(e){const t=e.allFieldInputs,r=new Set(t.map(e=>e.fieldName));for(const s of t){const e=s.multipleChoiceOtherChoiceFieldName;if(!e)continue;const t=s.layers[0]?.getField(e)?.name??e;r.has(t)&&(s.shouldShowMultipleChoiceOtherChoice=!1)}}function I(r,h){const{allFeatures:x,expressionsManager:w,getFieldValueOptionsForFeature:d,map:g}=h,F=new Set(r.layers),y=x.filter(e=>F.has(e.layer)),j=y.length===x.length;if(l(r))return new s({existsInAllLayers:j,features:y,template:r,expressionsManager:w,getFieldValueOptionsForFeature:d});if(p(r)){const e=r.elements.map(e=>I(e,h));return new n({existsInAllLayers:j,features:y,inputs:e,template:r,expressionsManager:w})}if(m(r))return new o({existsInAllLayers:j,features:y,template:r,expressionsManager:w});if(u(r))return new a({existsInAllLayers:j,features:y,template:r,expressionsManager:w});if(f(r))return new t({existsInAllLayers:j,features:y,template:r,expressionsManager:w});if(c(r))return new i({existsInAllLayers:j,features:y,template:r,expressionsManager:w,map:g});throw new e("batch-attribute-form:unsupported-element-template","The type of form element template provided is not supported")}export{h as createBatchFormInputsFromBatchFormTemplate};
|
|
2
|
+
import e from"../../../../core/Error.js";import t from"../AttachmentElementInput.js";import r from"../BatchFormInputs.js";import s from"../FieldInput.js";import n from"../GroupInput.js";import o from"../RelationshipElementInput.js";import a from"../TextElementInput.js";import i from"../UtilityNetworkAssociationsElementInput.js";import{isFieldElementTemplate as l,isGroupElementTemplate as p,isRelationshipElementTemplate as m,isTextElementTemplate as u,isAttachmentElementTemplate as f,isUtilityNetworkAssociationsElementTemplate as c}from"../../templates/support/templateUtils.js";function h(e,t){const s=new r({inputs:e.elements.map(e=>I(e,t)),template:e});return x(s),s}function x(e){const t=e.allFieldInputs,r=new Set(t.map(e=>e.fieldName));for(const s of t){const e=s.multipleChoiceOtherChoiceFieldName;if(!e)continue;const t=s.layers[0]?.getField(e)?.name??e;r.has(t)&&(s.shouldShowMultipleChoiceOtherChoice=!1)}}function I(r,h){const{allFeatures:x,expressionsManager:w,getFieldValueOptionsForFeature:d,map:g}=h,F=new Set(r.layers),y=x.filter(e=>F.has(e.layer)),j=y.length===x.length;if(l(r))return new s({existsInAllLayers:j,features:y,template:r,expressionsManager:w,getFieldValueOptionsForFeature:d});if(p(r)){const e=r.elements.map(e=>I(e,h));return new n({existsInAllLayers:j,features:y,inputs:e,template:r,expressionsManager:w})}if(m(r))return new o({existsInAllLayers:j,features:y,map:g,template:r,expressionsManager:w});if(u(r))return new a({existsInAllLayers:j,features:y,template:r,expressionsManager:w});if(f(r))return new t({existsInAllLayers:j,features:y,template:r,expressionsManager:w});if(c(r))return new i({existsInAllLayers:j,features:y,template:r,expressionsManager:w,map:g});throw new e("batch-attribute-form:unsupported-element-template","The type of form element template provided is not supported")}export{h as createBatchFormInputsFromBatchFormTemplate};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
function e(e){const{messages:n,onclick:
|
|
2
|
+
function e(e){const{messages:n,onclick:a}=e;return[{appearance:"solid",kind:"brand",message:n.footerButtons.add,onclick:a??(()=>{})}]}function n(e){const{callback:n,formId:a,messages:c}=e;return[{appearance:"solid",form:a,kind:"brand",message:c.footerButtons.update,onclick:()=>n()}]}function a(e){const{message:n,onclick:a}=e;return[{appearance:"outline",icon:"trash",kind:"danger",message:n,onclick:a??(()=>{})}]}function c(e){const{disabled:n,messages:a,onclick:c}=e;return[{appearance:"solid",disabled:n,kind:"brand",message:a.footerButtons.replace,onclick:c??(()=>{})}]}function s(e){const{messages:n,onclick:a}=e;return[{appearance:"outline",icon:"reset",kind:"brand",message:n.footerButtons.reset,onclick:a??(()=>{})}]}function o(e){const{deleteDisabled:n,deleteOnclick:a,doneOnclick:c,messages:s}=e;return[{appearance:"outline",kind:"brand",message:s.done,onclick:c??(()=>{})},{appearance:"outline",disabled:n,icon:"attachment",kind:"danger",message:s.delete,onclick:a??(()=>{})}]}export{e as makeAddAttachmentFooterButtons,n as makeDefaultFooterButtons,a as makeDiscardAttachmentFooterButtons,c as makeReplaceAttachmentFooterButtons,s as makeResetAttachmentFooterButtons,o as makeViewingAttachmentFooterButtons};
|
|
@@ -237,7 +237,7 @@ export interface FooterNoticeInfo {}
|
|
|
237
237
|
*
|
|
238
238
|
* @internal
|
|
239
239
|
*/
|
|
240
|
-
export type Page = "default" | "viewing-attachments" | "viewing-attachment-details" | "adding-attachments" | "viewing-associated-layers" | "viewing-associated-features";
|
|
240
|
+
export type Page = "default" | "viewing-attachments" | "viewing-attachment-details" | "replacing-attachment" | "adding-attachments" | "viewing-associated-layers" | "viewing-associated-features";
|
|
241
241
|
|
|
242
242
|
/**
|
|
243
243
|
* Configuration information about a selected attachment. Used to display details about the attachment.
|
|
@@ -266,6 +266,7 @@ export default class BatchAttributeForm extends Widget<BatchAttributeFormPropert
|
|
|
266
266
|
* Usually, this is called when the user clicks a specified `submit` button or when the form is programmatically submitted and calls the [FeatureLayer.applyEdits()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#applyEdits) method
|
|
267
267
|
* to update the features' attributes.
|
|
268
268
|
*
|
|
269
|
+
* @returns Resolves after any pending attachment hydration completes and the `"submit"` event has been emitted.
|
|
269
270
|
* @example
|
|
270
271
|
* // Listen for when 'submit' is called on the form.
|
|
271
272
|
* // Once it is fired, update the features.
|
|
@@ -274,5 +275,5 @@ export default class BatchAttributeForm extends Widget<BatchAttributeFormPropert
|
|
|
274
275
|
* // execute the 'submit()' method.
|
|
275
276
|
* document.getElementById("btnUpdate").addEventListener("click", () => form.submit());
|
|
276
277
|
*/
|
|
277
|
-
submit(): void
|
|
278
|
+
submit(): Promise<void>;
|
|
278
279
|
}
|