import type Accessor from "../../../core/Accessor.js"; import type FormTemplate from "../../../form/FormTemplate.js"; import type EditorEditingCapabilities from "./EditorEditingCapabilities.js"; import type { EditorLayerUnion, LayerInfo } from "../types.js"; export interface EditorItemProperties extends Partial> {} /** * A predominantly read-only editable item that corresponds to the feature being updated. This class is used by the [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/) widget to manage editing capabilities based on the provided layer and permissions set on it. It can be accessed through the Editor's [view model's editorItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/EditorViewModel/#editorItems). Although the returned collection is primarily read-only, it is possible to modify its [disabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/support/EditorItem/#disabled) property after construction. Also, it can be used in situations where custom functionality is used without the need to reference the [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/) widget directly. In this scenario, the item can be constructed and used to determine the editing capabilities for a specific layer. * * @since 4.30 * @see [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/) * @see [EditorViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/EditorViewModel/) * @example * //Create the Editor widget with a feature layer and form template * const editor = new Editor({ * view: view, * layerInfos: [{ * layer: featureLayer, // references an existing feature layer * formTemplate: formTemplate // references an existing form template * }] * }); * // Access the EditorItem from the Editor's view model * const editorItem = editor.viewModel.editorItems.find(item => item.layer === featureLayer); * //Check if the item is editable and if so, disable it * const isEditable = editorItem?.editable; * if (isEditable) { * editorItem.disabled = true; * } * @example * // This creates a new EditorItem instance without the need to reference the Editor widget. It determines the editing capabilities for a specific layer. * const editorItem = new EditorItem({ * layer: featureLayer, // This property is required if creating a new instance of EditorItem * layerInfo: featureLayerInfo * }); */ export default class EditorItem extends Accessor { /** * @example * // This creates a new EditorItem instance without the need to reference the Editor widget. It determines the editing capabilities for a specific layer. * const editorItem = new EditorItem({ * layer: featureLayer, // This property is required if creating a new instance of EditorItem * layerInfo: featureLayerInfo * }); */ constructor(properties?: EditorItemProperties); /** The current [editing capabilities](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/support/EditorEditingCapabilities/) for the provided layer. */ get capabilities(): EditorEditingCapabilities; /** * Indicates whether to override [editable](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/support/EditorItem/#editable) to `false`. This property is typically used for temporary UI purposes. For example, if an item needs to be visible in the UI, but not editable. * * @default false */ accessor disabled: boolean; /** * Indicates whether at least one edit operation is supported in [capabilities](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/support/EditorItem/#capabilities). It is primarily used for filtering layers eligible for editing. For UI purposes, specific permissions can still be confirmed using [capabilities](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/support/EditorItem/#capabilities). Additionally, [editable](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/support/EditorItem/#editable) takes into account the value for [disabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/support/EditorItem/#disabled) as a means to temporarily disable editing functionality. * * @default false */ get editable(): boolean; /** * A reference to the primary [FormTemplate](https://developers.arcgis.com/javascript/latest/references/core/form/FormTemplate/) in use. A form template set within the [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/) widget's [layerInfos](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/types/#LayerInfo) takes priority over a form template set directly on a [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) or [SubtypeSublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/SubtypeSublayer/). * * @see [Editor.layerInfos](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/types/#LayerInfo) * @see [FeatureLayer.formTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#formTemplate) * @see [SubtypeSublayer.formTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/support/SubtypeSublayer/#formTemplate) */ get formTemplate(): FormTemplate | null | undefined; /** * Indicates whether the primary [FormTemplate](https://developers.arcgis.com/javascript/latest/references/core/form/FormTemplate/) has an unknown (invalid) field. Editing is typically disabled in this scenario. * * @default false * @see [FeatureFormViewModel.valid](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureForm/FeatureFormViewModel/#valid) */ get hasInvalidFormTemplate(): boolean; /** * Indicates whether the associated layer is of type `Table`. * * @default false * @see [FeatureLayer.isTable](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#isTable) */ get isTable(): boolean; /** The layer currently being edited. */ accessor layer: EditorLayerUnion; /** * The [LayerInfo](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/types/#LayerInfo) for the provided layer. * * @see [Editor.layerInfos](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/#layerInfos) */ accessor layerInfo: LayerInfo | null | undefined; /** * Indicates whether the item supports starting a new [create features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/CreateFeaturesWorkflow/) workflow based on specific conditions set within the [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/). * * @default false */ get supportsCreateFeaturesWorkflow(): boolean; /** Indicates whether the item supports starting a new [merge features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/MergeFeaturesWorkflow/) workflow based on specific conditions set within the [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/). Merge workflows require both `update` and `create` permissions, as they both create a new feature and update an existing feature. */ get supportsMergeFeaturesWorkflow(): boolean; /** Indicates whether the item supports starting a new [split feature](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflow/) workflow based on specific conditions set within the [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/). Split workflows require both `update` and `create` permissions, as they both create a new feature and update an existing feature. */ get supportsSplitFeatureWorkflow(): boolean; /** * Indicates whether the item supports starting a new [update workflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/UpdateWorkflow/) based on specific conditions set within the [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/). * This includes allowing attachments even when `update` is not allowed, or preventing edits when the layer * or its parent are not visible. * * @default false */ get supportsUpdateWorkflow(): boolean; /** * Indicates whether the associated layer and its parent are visible. * * @default false */ get visible(): boolean; }