12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import{on as o,watch as l}from"../core/reactiveUtils.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as s}from"../core/accessorSupport/decorators/cast.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import a from"./FeatureTable/FeatureTableViewModel.js";import c from"./FeatureTable/Grid/support/ButtonMenu.js";import u from"./FeatureTable/Grid/support/ButtonMenuItem.js";import"./support/widgetUtils.js";import{messageBundle as h}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";import{onLocaleChange as p}from"../intl/locale.js";import{substitute as g}from"../intl/substitute.js";import{fetchMessageBundle as v}from"../intl/messages.js";const w={header:!0,menu:!0,menuItems:{clearSelection:!0,refreshData:!0,toggleColumns:!0,selectedRecordsShowAllToggle:!0,selectedRecordsShowSelectedToggle:!0,zoomToSelection:!0},selectionColumn:!0,columnMenus:!0},b={base:"esri-feature-table",header:"esri-feature-table__header",title:"esri-feature-table__title",content:"esri-feature-table__content",loader:"esri-feature-table__loader",loaderContainer:"esri-feature-table__loader-container",menuContainer:"esri-feature-table__menu",menuIcon:"esri-icon-handle-horizontal",menuItemGroupOpenedIcon:"esri-icon-down",menuItemGroupClosedIcon:"esri-icon-right",checkmarkIcon:"esri-icon-check-mark",widget:"esri-widget"};let f=class extends(t(d)){constructor(e,t){super(e,t),this.activeSortOrders=null,this.attachmentsEnabled=null,this.autoRefreshEnabled=null,this.columnReorderingEnabled=null,this.columns=null,this.editingEnabled=null,this.fieldConfigs=null,this.filterGeometry=null,this.grid=null,this.hiddenFields=null,this.highlightOnRowSelectEnabled=null,this.label=void 0,this.layer=null,this.messages=null,this.menu=null,this.menuConfig=null,this.multiSortEnabled=null,this.pageSize=null,this.relatedRecordsEnabled=null,this.state=null,this.tableTemplate=null,this.view=null,this.viewModel=new a,this.visibleElements={...w}}initialize(){const e=async()=>this.messages=await v("esri/widgets/FeatureTable/t9n/FeatureTable");e(),this.handles.add([p(e),o((()=>this.viewModel.columns),"change",(()=>this._syncMenuConfig())),o((()=>this.viewModel.activeFilters),"change",(()=>this._syncMenuConfig())),o((()=>this.grid.selectedItems),"change",(e=>{this._syncMenuConfig(),this._onSelectionChange(e)})),l((()=>[this.viewModel.store.querying,this.viewModel.store.syncing]),(()=>this.scheduleRender())),l((()=>this.menuConfig),(()=>this._syncMenuConfig())),l((()=>this.messages),(()=>{this.menu.label=this.messages?.options,this._syncMenuConfig()}))]),this._set("menu",new c({label:this.messages?.options,iconClass:b.menuIcon,...this.menuConfig}));const{attachmentsEnabled:t,relatedRecordsEnabled:i}=this;this.viewModel?.store?.set({attachmentsEnabled:t,relatedRecordsEnabled:i})}destroy(){this.clearSelection(),this.handles.removeAll(),this.menu?.destroy()}castVisibleElements(e){const t={...w,...e};return this.grid?.set("visibleElements",{...this.grid.visibleElements,selectionColumn:t.selectionColumn,columnMenus:t.columnMenus}),t}clearHighlights(){}clearSelection(){}clearSelectionFilter(){}deselectRows(){}filterBySelection(){}findColumn(){}hideColumn(e){this.grid?.hideColumn(e),this._syncMenuConfig()}refresh(){}showAllColumns(){}showColumn(e){this.grid?.showColumn(e),this._syncMenuConfig()}sortColumn(){}selectRows(){}scrollToIndex(){}render(){return m("div",{bind:this,class:this.classes(b.base,b.widget)},this.visibleElements.header?this._renderHeader():null,m("div",{class:b.content},"disabled"!==this.state&&this.grid?.render()))}zoomToSelection(){}_renderHeader(){return m("div",{key:"header",class:b.header},this._renderLoader(),this._renderTitle(),this.visibleElements.menu?this._renderMenu():null)}_renderTitle(){return m("div",{class:b.title,key:"title"},this._getTitle())}_getTitle(){const{grid:e,layer:t,messages:o,viewModel:{size:l}}=this;return e&&t?g(o.header,{title:t.title,count:l,selected:e.selectedItems.length||0}):""}_renderLoader(){const{state:e,store:t}=this.viewModel,o="loading"===e||t.syncing||t.querying;return m("div",{class:b.loaderContainer},o?m("div",{class:b.loader,key:"loader"}):null)}_renderMenu(){return m("div",{class:b.menuContainer},this.menu.render())}_onSelectionChange(e){const{added:t,removed:o}=e;this.emit("selection-change",{added:[...t],removed:[...o]})}_syncMenuConfig(){this.menu?.set({...this.menuConfig,items:this._getMenuItems()})}_getMenuItems(){const e=this.menuConfig?.items,t=this._getDefaultMenuItems(),o=[];return t?.length&&o.push(...t),e?.length&&o.push(...e),o}_getDefaultMenuItems(){const{messages:e,viewModel:t,visibleElements:o}=this,{menuItems:l}=o,i=[];if(l?.refreshData&&i.push(new u({selectionEnabled:!1,label:e?.refreshData,clickFunction:()=>this.refresh()})),this._hasActiveSelection()){const t=this.grid.selectedItems.length,o=this._getSelectionFilter();if(l?.clearSelection&&i.push(new u({selectionEnabled:!1,label:e?.clearSelection,clickFunction:()=>this.clearSelection()})),l?.zoomToSelection&&this.view&&i.push(new u({selectionEnabled:!1,label:e?.zoomToSelection,clickFunction:()=>this.viewModel.zoomToSelection()})),l?.selectedRecordsShowSelectedToggle&&(!o||t!==o.objectIds.length)){const t=e.showSelected,o=new u({selectionEnabled:!1,label:t,clickFunction:()=>{this.filterBySelection(),o.set("label",t)}});i.push(o)}}if(l?.selectedRecordsShowAllToggle&&this._hasSelectionFilter()){const t=e.showAllRecords,o=new u({selectionEnabled:!1,label:t,clickFunction:()=>{this.clearSelectionFilter(),o.set("label",t)}});i.push(o)}return l?.toggleColumns&&i.push(new u({iconClass:b.menuItemGroupClosedIcon,label:e?.toggleColumns,clickFunction:this._toggleMenuItemSelectedIcon,items:t?.columns?.items.map((({header:e,hidden:t,path:o})=>new u({label:e||o,selected:!t,selectionEnabled:!0,iconClass:b.checkmarkIcon,clickFunction:()=>this._toggleColumnFromMenuItem(o)})))})),i.length?i:null}_toggleMenuItemSelectedIcon({item:e}){e?.set("iconClass",e?.selected?b.menuItemGroupOpenedIcon:b.menuItemGroupClosedIcon)}_toggleColumnFromMenuItem(e){const{grid:t,viewModel:o}=this;o.findColumn(e)?.hidden?t.showColumn(e):t.hideColumn(e)}_hasActiveSelection(){return!!this.grid?.selectedItems?.length}_getSelectionFilter(){return this.viewModel.activeFilters?.find((e=>"selection"===e.type))}_hasSelectionFilter(){return!!this._getSelectionFilter()}};e([i("viewModel.activeSortOrders")],f.prototype,"activeSortOrders",void 0),e([i("viewModel.attachmentsEnabled")],f.prototype,"attachmentsEnabled",void 0),e([i("viewModel.autoRefreshEnabled")],f.prototype,"autoRefreshEnabled",void 0),e([i("viewModel.columnReorderingEnabled")],f.prototype,"columnReorderingEnabled",void 0),e([i("viewModel.columns")],f.prototype,"columns",void 0),e([i("viewModel.editingEnabled")],f.prototype,"editingEnabled",void 0),e([i("viewModel.fieldConfigs")],f.prototype,"fieldConfigs",void 0),e([i("viewModel.filterGeometry")],f.prototype,"filterGeometry",void 0),e([i("viewModel.grid")],f.prototype,"grid",void 0),e([i("viewModel.hiddenFields")],f.prototype,"hiddenFields",void 0),e([i("viewModel.highlightOnRowSelectEnabled")],f.prototype,"highlightOnRowSelectEnabled",void 0),e([n({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],f.prototype,"label",void 0),e([i("viewModel.layer")],f.prototype,"layer",void 0),e([n(),h("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",void 0),e([n({readOnly:!0})],f.prototype,"menu",void 0),e([n()],f.prototype,"menuConfig",void 0),e([i("viewModel.multiSortEnabled")],f.prototype,"multiSortEnabled",void 0),e([i("viewModel.pageSize")],f.prototype,"pageSize",void 0),e([i("viewModel.relatedRecordsEnabled")],f.prototype,"relatedRecordsEnabled",void 0),e([i("viewModel.state")],f.prototype,"state",void 0),e([i("viewModel.tableTemplate")],f.prototype,"tableTemplate",void 0),e([i("viewModel.view")],f.prototype,"view",void 0),e([n()],f.prototype,"viewModel",void 0),e([n()],f.prototype,"visibleElements",void 0),e([s("visibleElements")],f.prototype,"castVisibleElements",null),e([i("viewModel.clearHighlights")],f.prototype,"clearHighlights",null),e([i("viewModel.clearSelection")],f.prototype,"clearSelection",null),e([i("viewModel.clearSelectionFilter")],f.prototype,"clearSelectionFilter",null),e([i("viewModel.deselectRows")],f.prototype,"deselectRows",null),e([i("viewModel.filterBySelection")],f.prototype,"filterBySelection",null),e([i("viewModel.findColumn")],f.prototype,"findColumn",null),e([i("viewModel.refresh")],f.prototype,"refresh",null),e([i("viewModel.showAllColumns")],f.prototype,"showAllColumns",null),e([i("viewModel.sortColumn")],f.prototype,"sortColumn",null),e([i("viewModel.selectRows")],f.prototype,"selectRows",null),e([i("viewModel.scrollToIndex")],f.prototype,"scrollToIndex",null),e([i("viewModel.zoomToSelection")],f.prototype,"zoomToSelection",null),f=e([r("esri.widgets.FeatureTable")],f);const y=f;export{y as default};
|