From 18fe312ca9baf5ce399e5ba185188f41d6c5b8b1 Mon Sep 17 00:00:00 2001 From: Arun Date: Fri, 26 Feb 2016 13:33:18 +1300 Subject: [PATCH] First release of DrawMeasureWidget compatible with Webapp Builder 1.3. Dependencies folder updated with CustomUtils folder. README.md has the required info --- dependencies/CustomUtils/SimpleTable.js | 960 ++++++++++++++++++++++++ dependencies/README.md | 10 +- src/Buffer.js | 55 +- src/DynamicMeasure.js | 33 +- src/ExportUtil.js | 13 +- src/Widget.js | 140 +++- src/config.json | 56 +- src/images/icon.png | Bin 393 -> 1796 bytes src/manifest.json | 21 +- src/nls/strings.js | 2 + src/setting/Setting.html | 47 +- src/setting/Setting.js | 239 ++++-- src/setting/css/style.css | 15 +- src/setting/nls/strings.js | 5 +- 14 files changed, 1402 insertions(+), 194 deletions(-) create mode 100644 dependencies/CustomUtils/SimpleTable.js diff --git a/dependencies/CustomUtils/SimpleTable.js b/dependencies/CustomUtils/SimpleTable.js new file mode 100644 index 0000000..22dc84f --- /dev/null +++ b/dependencies/CustomUtils/SimpleTable.js @@ -0,0 +1,960 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright © 2014 Esri. All Rights Reserved. +// +// Licensed under the Apache License Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +/////////////////////////////////////////////////////////////////////////// + +/*GBS customised this module to display row text editors when edit button is clicked.. + edited methods: + _createEditableTextTd + _editEditableText + added methods + _hideRowEditor, + finishEditing + +*/ +///////////////////////////////////////////////////////////////////////////// + +define(['dojo/_base/declare', + 'dijit/_WidgetBase', + 'dijit/_TemplatedMixin', + 'dojo/Evented', + 'dojo/_base/lang', + 'dojo/_base/html', + 'dojo/_base/array', + 'dojo/on', + 'dojo/query', + 'jimu/utils' + ], + function(declare, _WidgetBase, _TemplatedMixin, Evented, lang, html, array, on, query, + jimuUtils) { + return declare([_WidgetBase, _TemplatedMixin, Evented], { + baseClass: 'jimu-simple-table', + declaredClass: 'jimu.dijit.SimpleTable', + templateString: '
' + + '
' + + '
' + + '
' + + '' + + '' + + '' + + '' + + '
' + + '
' + + '
' + + '
', + _name: null, + _rowIndex: 0, + _rowHeight: 30, + _headHeight: 36, + REPEATING_ERROR: "REPEATING_ERROR", + _classSimpleTableRow: 'simple-table-row', + _classFirstSimpleTableRow: 'first-simple-table-row', + _classLastSimpleTableRow: 'last-simple-table-row', + _classJimuStateDisabled: 'jimu-state-disabled', + _classRowUpDiv: 'row-up-div', + _classRowDownDiv: 'row-down-div', + + //options: + autoHeight: true, //if true, automatically calculate the height + selectable: false, + fields: null, + /* + //fieldInfo's attributes: + //name:field name + //title:field title + //type:text radio checkbox actions empty extension + //class:class name of th and td + //width:width of the field column, auto is default. + //hidden:default false.If true,the field column will be hidden. + //if text + //editable:the text can be edited if true. + //unique:field value is unique in the column. + //if actions + //actions:['up','down','edit','delete'] + //if extension + //create //function + //setValue //function + //getValue //function + */ + + //public methods: + //clear + //clearEmptyRows + //addEmptyRow + //addRows + //addRow + //deleteRow + //editRow + //selectRow + //getRows + //getSelectedRow + //getSelectedRowData + //getData + //getRowData + //getRowDataArrayByFieldValue + + //events: + //row-click + //row-dblclick + //row-select + //rows-clear + //row-add + //row-edit + //row-delete + //row-up + //row-down + //actions-edit + + //css classes: + //simple-table-title + //simple-table-row + //simple-table-field + //simple-table-cell + + postMixInProperties: function(){ + this.nls = window.jimuNls.simpleTable; + }, + + postCreate: function() { + this.inherited(arguments); + this._initSelf(); + }, + + startup: function() { + this.inherited(arguments); + this._updateUI(); + }, + + _initSelf: function() { + this._initAttachPoints(); + + this.own( + jimuUtils.bindClickAndDblclickEvents(this.table, + lang.hitch(this, function(evt) { + var target = evt.target || evt.srcElement; + var tr = jimuUtils.getAncestorDom(target, function(dom) { + return html.hasClass(dom, 'simple-table-row') && html.hasClass(dom, 'not-empty'); + }, this.tbody); + if(tr){ + this.selectRow(tr); + this._onClickRow(tr); + } + }), lang.hitch(this, function(evt) { + var target = evt.target || evt.srcElement; + var tr = jimuUtils.getAncestorDom(target, function(dom) { + return html.hasClass(dom, 'simple-table-row') && html.hasClass(dom, 'not-empty'); + }, this.tbody); + if(tr){ + this.selectRow(tr); + this._onDblClickRow(tr); + } + })) + ); + + var num = Math.random().toString(); + this._name = 'jimu_table_' + num.slice(2, num.length); + this.thead = query('thead', this.domNode)[0]; + this.tbody = query('tbody', this.domNode)[0]; + + if (this.fields && this.fields.length > 0) { + var tr = html.create('tr', {}, this.thead); + array.forEach(this.fields, lang.hitch(this, function(item){ + var width = 'auto'; + if(item.type === 'actions'){ + item.name = 'actions'; + } + + if(item.hidden){ + width = 1; + } + else if(item.width !== undefined && item.width !== null){ + width = item.width; + } + else if(item.type === 'actions'){ + if(!item.name){ + item.width = this._calculateActionsWidth(item) + 20; + width = item.width; + } + } + + html.create('col', {width:width}, this.colgroup); + var th = html.create('th', { + innerHTML: item.title, + title: item.title + }, tr); + + html.addClass(th, 'simple-table-field'); + + if(item.hidden){ + html.addClass(th, 'hidden-column'); + } + + if (item['class']) { + html.addClass(th, item['class']); + } + html.addClass(th, item.name); + })); + + //clone thead + html.empty(this.headDiv); + var tableDiv = lang.clone(this.tableDiv); + html.place(tableDiv, this.headDiv); + + //this.addEmptyRow(); + } else { + this.fields = null; + } + }, + + _initAttachPoints:function(){ + this.table = query('table', this.bodyDiv)[0]; + this.colgroup = query('colgroup', this.bodyDiv)[0]; + this.head = query('thead', this.bodyDiv)[0]; + this.tbody = query('tbody', this.bodyDiv)[0]; + }, + + clear: function() { + var trs = this._getNotEmptyRows(); + html.empty(this.tbody); + array.forEach(trs, lang.hitch(this, function(tr) { + this._onDeleteRow(tr); + })); + //this.addEmptyRow(); + this._updateUI(); + this._rowIndex = 0; + this._onClearRows(trs); + }, + + // clearEmptyRows: function() { + // var trs = this._getEmptyRows(); + // array.forEach(trs, lang.hitch(this, function(tr) { + // html.destroy(tr); + // })); + // this._updateUI(); + // }, + + // addEmptyRow: function() { + // if (!this.fields) { + // return; + // } + + // this.clearEmptyRows(); + // var length = this.fields.length; + // var tr = html.create('tr', { + // 'class': 'simple-table-row empty' + // }, this.tbody); + // for (var i = 0; i < length; i++) { + // html.create('td', { + // 'class': 'simple-table-cell empty-td' + // }, tr); + // } + // this._updateRowClassName(); + // }, + + addRows: function(rowsData) { + var results = []; + if (this.fields && rowsData && rowsData.length > 0) { + array.forEach(rowsData, lang.hitch(this, function(item) { + results.push(this.addRow(item, true)); + })); + } + this._updateUI(); + return results; + }, + + //example:{name1:value1,name2:value2...} + addRow: function(rowData, /* optional */ dontUpdateUI) { + this._rowIndex++; + var result = { + success: false, + tr: null, + errorCode: null, + errorMessage: null, + repeatFields: null + }; + if (!this.fields || (typeof rowData !== 'object')) { + return result; + } + + var uniqueFieldMetas = array.filter(this.fields, lang.hitch(this, function(item) { + return item.type === 'text' && item.unique === true; + })); + + var repeatFieldMetas = array.filter(uniqueFieldMetas, lang.hitch(this, function(item) { + var sameValueRows = this.getRowDataArrayByFieldValue(item.name, rowData[item.name]); + return sameValueRows.length > 0; + })); + + if (repeatFieldMetas.length > 0) { + result.errorCode = this.REPEATING_ERROR; + result.errorMessage = "repeating data"; + result.repeatFields = repeatFieldMetas; + return result; + } + + // this.clearEmptyRows(); + var tr = html.create("tr", { + 'class': "simple-table-row not-empty" + }, this.tbody); + var rowId = 'row' + this._rowIndex; + html.setAttr(tr, 'rowId', rowId); + + array.forEach(this.fields, lang.hitch(this, function(fieldMeta) { + var fieldData = rowData[fieldMeta.name]; + var type = fieldMeta.type; + var td = null; + if (type === 'actions') { + td = this._createActionsTd(tr, fieldMeta); + } else { + if (type === "text") { + td = this._createTextTd(tr, fieldMeta, fieldData); + } else if (type === "radio") { + td = this._createRadioTd(tr, fieldMeta, fieldData); + } else if (type === 'checkbox') { + td = this._createCheckboxTd(tr, fieldMeta, fieldData); + } else if (type === "empty") { + td = this._createEmptyTd(tr, fieldMeta); + } + else if(type === "extension"){ + td = this._createExtensionTd(tr, fieldMeta, fieldData); + } + if(fieldMeta.hidden){ + html.addClass(td, 'hidden-column'); + } + } + })); + if(!dontUpdateUI){ + this._updateUI(); + } + result.success = true; + result.tr = tr; + result.errorMessage = null; + this._onAddRow(tr); + return result; + }, + + deleteRow:function(tr){ + if(tr){ + html.destroy(tr); + this._updateUI(); + this._onDeleteRow(tr); + // var trs = this._getAllRows(); + // if(trs.length === 0){ + // this.addEmptyRow(); + // } + } + }, + + selectRow:function(tr){ + if(this.selectable){ + var trs = query('.simple-table-row', this.tbody); + trs.removeClass('jimu-state-active'); + html.addClass(tr, 'jimu-state-active'); + this._onSelectRow(tr); + } + }, + + _updateUI: function(){ + this._updateRowClassName(); + this._updateHeight(); + }, + + _updateHeight: function(){ + if(this.autoHeight){ + var rows = this.getRows(); + var trCount = rows.length > 0 ? rows.length : 1; + // var count = trCount + 1; + var height = this._headHeight + this._rowHeight * trCount + 1; + html.setStyle(this.domNode, 'height', height + 'px'); + // this.bodyDiv.style.overflowY = 'hidden'; + } + }, + + _updateRowClassName: function() { + var originalFirtTr = query('.' + this._classFirstSimpleTableRow, this.tbody)[0]; + if(originalFirtTr){ + var originalFirstUpDiv = query('.' + this._classRowUpDiv, originalFirtTr)[0]; + if(originalFirstUpDiv){ + html.removeClass(originalFirstUpDiv, this._classJimuStateDisabled); + } + } + + var originalLastTr = query('.' + this._classLastSimpleTableRow, this.tbody)[0]; + if(originalLastTr){ + var originalLastDownDiv = query('.' + this._classRowDownDiv, originalLastTr)[0]; + if(originalLastDownDiv){ + html.removeClass(originalLastDownDiv, this._classJimuStateDisabled); + } + } + + var trs = query('.' + this._classSimpleTableRow, this.tbody); + trs.removeClass('odd'); + trs.removeClass('even'); + trs.removeClass(this._classFirstSimpleTableRow); + trs.removeClass(this._classLastSimpleTableRow); + + array.forEach(trs, lang.hitch(this, function(tr, index) { + if (index % 2 === 0) { + html.addClass(tr, 'odd'); + } else { + html.addClass(tr, 'even'); + } + })); + + if(trs.length > 0){ + var firstTr = trs[0]; + html.addClass(firstTr, this._classFirstSimpleTableRow); + var firstUpDiv = query('.' + this._classRowUpDiv, firstTr)[0]; + if(firstUpDiv){ + html.addClass(firstUpDiv, this._classJimuStateDisabled); + } + + var lastTr = trs[trs.length - 1]; + html.addClass(lastTr, this._classLastSimpleTableRow); + var lastDownDiv = query('.' + this._classRowDownDiv, lastTr)[0]; + if(lastDownDiv){ + html.addClass(lastDownDiv, this._classJimuStateDisabled); + } + } + }, + + _createTextTd: function(tr, fieldMeta, fieldData) { + var td = null; + if (fieldMeta.editable) { + td = this._createEditableTextTd(tr, fieldMeta, fieldData); + } else { + td = this._createNormalTextTd(tr, fieldMeta, fieldData); + } + return td; + }, + + _createNormalTextTd: function(tr, fieldMeta, fieldData) { + var strTd = '' + + '
'; + var td = html.toDom(strTd); + html.addClass(td, fieldMeta.name); + var textDiv = query('div', td)[0]; + textDiv.innerHTML = fieldData || ""; + textDiv.title = fieldData || ""; + if (fieldMeta['class']) { + html.addClass(td, fieldMeta['class']); + } + html.place(td, tr); + return td; + }, + + _createEditableTextTd: function(tr, fieldMeta, fieldData) { + var tdStr = '' + + '
' + + '
'; + var td = html.toDom(tdStr); + html.addClass(td, 'simple-table-cell'); + html.place(td, tr); + if (fieldMeta['class']) { + html.addClass(td, fieldMeta['class']); + } + var editableDiv = query('div', td)[0]; + var editableInput = query('input', td)[0]; + editableDiv.innerHTML = fieldData || ""; + if (editableDiv.innerHTML !== "") { + editableDiv.title = editableDiv.innerHTML; + } + editableInput.value = editableDiv.innerHTML; + this.own(on(editableDiv, 'dblclick', lang.hitch(this, function(event) { + event.stopPropagation(); + this.finishEditing();//gbs customization + editableInput.value = editableDiv.innerHTML; + html.setStyle(editableDiv, 'display', 'none'); + html.setStyle(editableInput, 'display', 'inline'); + editableInput.focus(); + }))); + this.own(on(editableInput, 'blur', lang.hitch(this, function() { + editableInput.value = lang.trim(editableInput.value); + var oldValue = editableDiv.innerHTML; + var newValue = editableInput.value; + if (newValue !== '') { + if (fieldMeta.unique) { + var sameValueRows = this.getRowDataArrayByFieldValue(fieldMeta.name, newValue, tr); + if (sameValueRows.length > 0) { + editableInput.value = oldValue; + } else { + editableDiv.innerHTML = newValue; + } + } else { + editableDiv.innerHTML = newValue; + } + } else { + editableDiv.innerHTML = ''; + editableInput.value = ''; + } + + html.setStyle(editableInput, 'display', 'none'); + html.setStyle(editableDiv, 'display', 'block'); + }))); + return td; + }, + + _createRadioTd: function(tr, fieldMeta, fieldData) { + var tdStr = ''; + var td = html.toDom(tdStr); + html.addClass(td, 'simple-table-cell'); + html.place(td, tr); + if (fieldMeta['class']) { + html.addClass(td, fieldMeta['class']); + } + var radio = query('input', td)[0]; + if (fieldMeta.radio && fieldMeta.radio === "row") { + radio.name = this._name + this._rowIndex; + } else { + radio.name = this._name + fieldMeta.name; + } + + radio.checked = fieldData === true; + return td; + }, + + _createCheckboxTd: function(tr, fieldMeta, fieldData) { + var tdStr = ''; + var td = html.toDom(tdStr); + html.addClass(td, 'simple-table-cell'); + html.place(td, tr); + if (fieldMeta['class']) { + html.addClass(td, fieldMeta['class']); + } + var checkbox = query('input', td)[0]; + checkbox.checked = fieldData === true; + return td; + }, + + _createActionsTd: function(tr, fieldMeta) { + var tdStr = '' + + '
'; + var td = html.toDom(tdStr); + html.addClass(td, 'simple-table-cell'); + var actionItemParent = query(".action-item-parent", td)[0]; + html.place(td, tr); + if (fieldMeta['class']) { + html.addClass(td, fieldMeta['class']); + } + + array.forEach(fieldMeta.actions, lang.hitch(this, function(item) { + if (item === 'up') { + var moveupDiv = html.create('div', { + 'class': 'action-item jimu-float-leading row-up-div jimu-icon jimu-icon-up' + }, actionItemParent); + moveupDiv.title = this.nls.moveUp; + this.own(on(moveupDiv, 'click', lang.hitch(this, function(event) { + event.stopPropagation(); + + if (!this.onBeforeRowUp(tr)){ + return; + } + var trs = query('.simple-table-row', this.tbody); + var index = array.indexOf(trs, tr); + if (index > 0) { + var newIndex = index - 1; + var trRef = trs[newIndex]; + if (trRef) { + html.place(tr, trRef, 'before'); + this._updateUI(); + this.emit('row-up', tr); + } + } + }))); + } else if (item === 'down') { + var movedownDiv = html.create('div', { + 'class': 'action-item jimu-float-leading row-down-div jimu-icon jimu-icon-down' + }, actionItemParent); + movedownDiv.title = this.nls.moveDown; + this.own(on(movedownDiv, 'click', lang.hitch(this, function(event) { + event.stopPropagation(); + + if (!this.onBeforeRowDown(tr)){ + return; + } + var trs = query('.simple-table-row', this.tbody); + var index = array.indexOf(trs, tr); + if (index < trs.length - 1) { + var newIndex = index + 1; + var trRef = trs[newIndex]; + if (trRef) { + html.place(tr, trRef, 'after'); + this._updateUI(); + this.emit('row-down', tr); + } + } + }))); + } else if (item === 'edit') { + var editDiv = html.create('div', { + 'class': 'action-item jimu-float-leading row-edit-div jimu-icon jimu-icon-edit' + }, actionItemParent); + editDiv.title = this.nls.edit; + this.own(on(editDiv, 'click', lang.hitch(this, function(event) { + event.stopPropagation(); + + if (!this.onBeforeRowEdit(tr)){ + return; + } + this._onActionsEdit(tr); + }))); + } else if (item === 'delete') { + var deleteDiv = html.create('div', { + 'class': 'action-item jimu-float-leading row-delete-div jimu-icon jimu-icon-delete' + }, actionItemParent); + deleteDiv.title = this.nls.deleteRow; + this.own(on(deleteDiv, 'click', lang.hitch(this, function(event) { + event.stopPropagation(); + + if (!this.onBeforeRowDelete(tr)){ + return; + } + this.deleteRow(tr); + }))); + } + })); + var width = this._calculateActionsWidth(fieldMeta) + 'px'; + html.setStyle(actionItemParent, 'width', width); + return td; + }, + + _calculateActionsWidth:function(fieldMeta){ + var items = array.map(fieldMeta.actions, function(item){ + return item === 'up' || item === 'down' || item === 'edit' || item === 'delete'; + }); + return items.length * 20; + }, + + _createEmptyTd: function(tr, fieldMeta) { + var td = html.create('td', { + 'class': fieldMeta.name + }, tr); + html.addClass(td, 'simple-table-cell'); + html.addClass(td, 'empty-text-td'); + if (fieldMeta['class']) { + html.addClass(td, fieldMeta['class']); + } + return td; + }, + + _createExtensionTd: function(tr, fieldMeta, fieldData){ + var td = html.create('td', { + 'class': fieldMeta.name + }, tr); + html.addClass(td, 'simple-table-cell'); + html.addClass(td, 'extension-td'); + if (fieldMeta['class']){ + html.addClass(td, fieldMeta['class']); + } + if(fieldMeta.create && typeof fieldMeta.create === 'function'){ + fieldMeta.create(td); + } + if(fieldMeta.setValue && typeof fieldMeta.setValue === 'function'){ + fieldMeta.setValue(td, fieldData); + } + return td; + }, + + editRow: function(tr, rowData) { + var result = { + success: false, + tr: null, + errorCode: null, + errorMessage: null, + repeatFields: null + }; + if (!this.fields || (typeof rowData !== 'object')) { + return result; + } + if (!html.isDescendant(tr, this.tbody)) { + return result; + } + var allFieldMetas = lang.mixin([], this.fields); + var uniqueFieldMetas = array.filter(allFieldMetas, lang.hitch(this, function(item) { + return item.type === 'text' && item.unique === true; + })); + + var repeatFieldMetas = array.filter(uniqueFieldMetas, lang.hitch(this, function(item) { + var sameValueRows = this.getRowDataArrayByFieldValue(item.name, rowData[item.name], tr); + return sameValueRows.length > 0; + })); + + if (repeatFieldMetas.length > 0) { + result.errorCode = this.REPEATING_ERROR; + result.errorMessage = "repeating data"; + result.repeatFields = repeatFieldMetas; + return result; + } + var tds = query('.simple-table-cell', tr); + array.forEach(this.fields, lang.hitch(this, function(fieldMeta, idx) { + if (!rowData.hasOwnProperty(fieldMeta.name)) { + return; + } + var td = tds[idx]; + var fieldData = rowData[fieldMeta.name]; + var type = fieldMeta.type; + if (type === 'text') { + if (fieldMeta.editable) { + this._editEditableText(td, fieldMeta, fieldData); + } else { + this._editNormalText(td, fieldMeta, fieldData); + } + } else if (type === 'radio') { + this._editRadio(td, fieldMeta, fieldData); + } else if (type === 'checkbox') { + this._editCheckbox(td, fieldMeta, fieldData); + } + else if(type === 'extension'){ + this._editExtension(td, fieldMeta, fieldData); + } + })); + result.success = true; + result.tr = tr; + result.errorMessage = null; + this._onEditRow(tr); + return result; + }, + + _editNormalText: function(td, fieldMeta, fieldData) { + /*jshint unused: false*/ + var normalTextDiv = query('div', td)[0]; + normalTextDiv.innerHTML = fieldData || ""; + normalTextDiv.title = normalTextDiv.innerHTML; + }, + + _editEditableText: function(td, fieldMeta, fieldData) { + /*jshint unused: false*/ + var editableDiv = query('div', td)[0]; + editableDiv.innerHTML = fieldData || ""; + var editableInput = query('input', td)[0]; + editableInput.value = editableDiv.innerHTML; + + html.setStyle(editableDiv, 'display', 'none');//gbs customization + html.setStyle(editableInput, 'display', 'inline');//gbs customization + }, + + _editRadio: function(td, fieldMeta, fieldData) { + /*jshint unused: false*/ + var radio = query('input', td)[0]; + radio.checked = fieldData === true; + }, + + _editCheckbox: function(td, fieldMeta, fieldData) { + /*jshint unused: false*/ + var checkbox = query('input', td)[0]; + checkbox.checked = fieldData === true; + }, + + _editExtension: function(td, fieldMeta, fieldData){ + if(fieldMeta.setValue && typeof fieldMeta.setValue === 'function'){ + fieldMeta.setValue(td, fieldData); + } + }, + + _getAllRows: function(){ + return query('.simple-table-row', this.tbody); + }, + + _getNotEmptyRows: function() { + var trs = this._getAllRows(); + return array.filter(trs, lang.hitch(this, function(tr) { + return !html.hasClass(tr, 'empty'); + })); + }, + + _getEmptyRows: function() { + var trs = this._getAllRows(); + return array.filter(trs, lang.hitch(this, function(tr) { + return html.hasClass(tr, 'empty'); + })); + }, + + getRows: function() { + return this._getNotEmptyRows(); + }, + + getSelectedRow: function() { + var result = null; + var trs = query('.simple-table-row', this.tbody); + var filterTrs = array.filter(trs, lang.hitch(this, function(tr) { + return !html.hasClass(tr, 'empty') && html.hasClass(tr, 'jimu-state-active'); + })); + if (filterTrs.length > 0) { + result = filterTrs[0]; + } + return result; + }, + + getSelectedRowData: function() { + var result = null; + var tr = this.getSelectedRow(); + if (tr) { + result = this._getRowDataByTr(tr); + } + return result; + }, + + getData: function(/*optional*/ ignoredTr) { + var trs = this._getNotEmptyRows(); + if(ignoredTr){ + trs = array.filter(trs, lang.hitch(this, function(tr){ + return tr !== ignoredTr; + })); + } + var result = array.map(trs, lang.hitch(this, function(tr) { + return this._getRowDataByTr(tr); + })); + return result; + }, + + getRowData: function(tr) { + return this._getRowDataByTr(tr); + }, + _hideRowEditor:function(tr){ + var tds = query('.simple-table-cell', tr); + array.forEach(tds, function (td) { + /*jshint unused: false*/ + var editableDiv = query('div', td)[0]; + var editableInput = query('input', td)[0]; + if (editableInput) { + editableInput.blur(); + html.setStyle(editableInput, 'display', 'none'); + html.setStyle(editableDiv, 'display', 'block'); + } + + }); + }, + finishEditing: function () { + //clear all active editors + var rows = this.getRows(); + array.forEach(rows,lang.hitch(this, function (tr) { + this._hideRowEditor(tr); + })); + }, + _getRowDataByTr: function(tr) { + var rowData = null; + if (tr) { + rowData = {}; + } else { + return null; + } + array.forEach(this.fields, lang.hitch(this, function(fieldMeta) { + var type = fieldMeta.type; + if (type === 'actions') { + return; + } + var name = fieldMeta.name; + rowData[name] = null; + var td = query('.' + name, tr)[0]; + if (td) { + if (type === 'text') { + if (fieldMeta.editable) { + var editableDiv = query('div', td)[0]; + rowData[name] = editableDiv.innerHTML; + } else { + var normalTextDiv = query('div', td)[0]; + rowData[name] = normalTextDiv.innerHTML; + } + } else if (type === 'radio') { + var radio = query('input', td)[0]; + rowData[name] = radio.checked; + } else if (type === 'checkbox') { + var checkbox = query('input', td)[0]; + rowData[name] = checkbox.checked; + } + else if(type === 'extension'){ + if(fieldMeta.getValue && typeof fieldMeta.getValue === 'function'){ + rowData[name] = fieldMeta.getValue(td, fieldMeta); + } + } + } + })); + return rowData; + }, + + getRowDataArrayByFieldValue: function(fieldName, fieldValue, /*optional*/ ignoredTr) { + var result = []; + if (!this.fields) { + return []; + } + var validField = array.some(this.fields, lang.hitch(this, function(item) { + return item.name === fieldName; + })); + if (!validField) { + return []; + } + var rows = this.getData(ignoredTr); + result = array.filter(rows, lang.hitch(this, function(row) { + /* jshint eqeqeq: false*/ + return row[fieldName] == fieldValue; + })); + return result; + }, + + _onClickRow: function(tr){ + this.emit('row-click', tr); + }, + + _onDblClickRow: function(tr){ + this.emit('row-dblclick', tr); + }, + + _onSelectRow: function(tr){ + this.emit('row-select', tr); + }, + + _onAddRow: function(tr){ + this.emit('row-add', tr); + }, + + _onEditRow: function(tr){ + this.emit('row-edit', tr); + }, + + _onDeleteRow: function(tr){ + this.emit('row-delete', tr); + }, + + _onEnterRow: function(tr){ + this.emit('row-enter', tr); + }, + + _onClearRows: function(trs){ + this.emit('rows-clear', trs); + }, + + _onActionsEdit: function(tr){ + this.emit('actions-edit', tr); + }, + + onBeforeRowUp: function(tr){ + /*jshint unused : false*/ + return true; + }, + + onBeforeRowDown: function(tr){ + /*jshint unused : false*/ + return true; + }, + + onBeforeRowEdit: function(tr){ + /*jshint unused : false*/ + return true; + }, + + onBeforeRowDelete: function(tr){ + /*jshint unused : false*/ + return true; + } + }); + }); \ No newline at end of file diff --git a/dependencies/README.md b/dependencies/README.md index ffc5a56..1ec20d4 100644 --- a/dependencies/README.md +++ b/dependencies/README.md @@ -5,4 +5,12 @@ This folder provides top level access to any widget dependencies. This may inclu - Server Object Extension Source Code - Python Scripts - Geoprocessing Models -- SQL Scripts \ No newline at end of file +- SQL Scripts + +Important Notes + +1. "CustomUtils" folder contains any utility,library files which may be required for the widgets delivered.This is a frame-work level utility folder which has to reside in + /client/stemapp/jimu.js/ + +2. Content of SymbolsInfo folder has to be copied to /client/stemapp/jimu.js/dijit/SymbolsInfo path and use the file name ("picturemarker") to configure + the Picturemarker configuration section of DrawMeasureWidget. \ No newline at end of file diff --git a/src/Buffer.js b/src/Buffer.js index ba0e58c..451b6af 100644 --- a/src/Buffer.js +++ b/src/Buffer.js @@ -51,7 +51,7 @@ define( }, _mousetip: null, _isActive: false, - constructor: function (container, map, layer, config) { + constructor: function (container, map, layer,nls, config) { this.domNode = domConstruct.create("div", { "title": "Buffer", "data-geotype": "BUFFER", @@ -62,6 +62,7 @@ define( this._setMap(map); this._setLayer(layer); this._setConfig(config); + this._setNls(nls); this._createMousetip(); }, _setMap: function (map) { @@ -73,6 +74,9 @@ define( _setConfig: function (config) { this.config = config; }, + _setNls:function(nls){ + this.nls = nls; + }, setParams: function (a, b, c) { this._distance = a; this._unit = b; @@ -82,26 +86,51 @@ define( var me = this; this._isActive = true; this._activateMouseTip(); - domClass.add(this.domNode, "selected"); + domClass.add(this.domNode, "jimu-state-active"); if (!this._clickHandle) { this._clickHandle = connect.connect(this._map, "onClick", function (evt) { var extentGeom = me.pointToExtent(evt.mapPoint, me._map); + var sourceGraphicIndex; var filteredGraphics = array.filter(me._layer.graphics, function (graphic, index) { - return extentGeom.contains(graphic.geometry) || extentGeom.intersects(graphic.geometry); + if (extentGeom.contains(graphic.geometry) || extentGeom.intersects(graphic.geometry)) { + sourceGraphicIndex = index; + return true; + } }); if (filteredGraphics.length > 0) { - me.doBuffer(filteredGraphics[0]).then(function (bufferGeom) { - var bufferGraphic = new Graphic(bufferGeom, me._symbology, { uniqueId: new Date().getTime() }); + var sourceGraphic = filteredGraphics[0]; + me.doBuffer(sourceGraphic).then(function (bufferGeom) { + var bufferGraphic = new Graphic(bufferGeom, me._symbology, { uniqueId: new Date().getTime(),pariId:"Pari" }); me._layer.add(bufferGraphic); if (bufferGraphic && bufferGraphic.getDojoShape()) { if (me._distance <= 0) { bufferGraphic.getDojoShape().moveToFront(); } else { - bufferGraphic.getDojoShape().moveToBack(); + //swapping the positions of orginal and buffer in the layer.graphics array + //so that the smaller one comes on top when imported from a mpk file + var sourceAttributes = lang.clone(sourceGraphic.attributes); + var sourceGeometry = lang.clone(sourceGraphic.geometry); + var sourceSymbol = lang.clone(sourceGraphic.symbol); + + var bufferAttributes = lang.clone(bufferGraphic.attributes); + var buffereGeometry = lang.clone(bufferGraphic.geometry); + var bufferSymbol = lang.clone(bufferGraphic.symbol); + + + bufferGraphic.setGeometry(sourceGeometry); + bufferGraphic.setAttributes(sourceAttributes); + bufferGraphic.setSymbol(sourceSymbol); + + + sourceGraphic.setGeometry(buffereGeometry); + sourceGraphic.setAttributes(bufferAttributes); + sourceGraphic.setSymbol(bufferSymbol); + + //sourceGraphic and bufferGraphic are now swapped by now in terms of geometry/attributes + sourceGraphic.getDojoShape().moveToBack(); } } topic.publish("BUFFER_GRAPHIC_ADDED", bufferGraphic); - }, function () { me._showErrorMessage(); }) @@ -114,7 +143,7 @@ define( deactivate: function () { this._isActive = false; this._deactivateTooltip(); - domClass.remove(this.domNode, "selected"); + domClass.remove(this.domNode, "jimu-state-active"); if (this._clickHandle) { connect.disconnect(this._clickHandle); this._clickHandle = null; @@ -141,8 +170,8 @@ define( return extent; }, _createMousetip: function () { - if (this.config.mousetip) { - this._mousetip = domConstruct.create("div", { "class": "mousetip", "innerHTML": this.config.mousetip }, this._map.container); + if (this.nls.mousetip) { + this._mousetip = domConstruct.create("div", { "class": "mousetip", "innerHTML": this.nls.mousetip }, this._map.container); domStyle.set(this._mousetip, { "position": "fixed", "display": "none" @@ -187,7 +216,9 @@ define( connect.disconnect(this._mousetipHandle.mouseMove); this._mousetipHandle.mouseMove = null; } - this._mousetip.style.display = "none"; + if (this._mousetip) { + this._mousetip.style.display = "none"; + } }, doBuffer: function (graphic) { var me = this; @@ -216,7 +247,7 @@ define( }, _showErrorMessage: function () { var popup = new Message({ - message: this.config.invalidRequestMessage, + message: this.nls.invalidRequestMessage, buttons: [{ label: "OK", onClick: lang.hitch(this, function () { diff --git a/src/DynamicMeasure.js b/src/DynamicMeasure.js index baac065..6efcff8 100644 --- a/src/DynamicMeasure.js +++ b/src/DynamicMeasure.js @@ -138,7 +138,6 @@ define( calculateMeasurement([drawToolbar._tGraphic,drawToolbar._customGraphic]); } } - } })); aspect.after(drawToolbar, "_onClickHandler", lang.hitch(this, function (orginalFn) { @@ -232,8 +231,10 @@ define( var distanceAbbr = this._distanceAbbr; if (this._tool._tooltip && type === "distance") { this._tool._tooltip.style.display = ""; - this._tool._tooltip.style.width = "120px"; - this._tool._tooltip.style.height = "40px"; + this._tool._tooltip.style.minWidth = "120px"; + this._tool._tooltip.style.minHeight = "40px"; + this._tool._tooltip.style.height = "auto"; + this._tool._tooltip.style.width = "auto"; if (measurements.length == 1) { instructionText = "Let go to finish.
"; } else if (measurements.length == 2 ) { @@ -241,9 +242,9 @@ define( instructionText += "Click to continue drawing.
"; this._tool._tooltip.style.width = "145px"; } - instructionText += "Distance : " + measurements[0] + distanceAbbr+ "
"; + instructionText += "Distance : " + measurements[0] + distanceAbbr+ ""; if (measurements.length == 2) { - instructionText += "Total : " + measurements[1] +distanceAbbr+ ""; + instructionText += "
Total : " + measurements[1] + distanceAbbr + ""; this._tool._tooltip.style.height = "85px"; } this._tool._tooltip.innerHTML = instructionText; @@ -254,28 +255,6 @@ define( domClass.remove(this._tool._tooltip, "measure-loading"); } }, - _updateMeasurementInTootip: function (measureObj) { - if (measureObj.type === "length") { - var prefix = measureObj.message; - if (measureObj.singleSegment) { - var msg = prefix+"Distance: "+ measureObj.total; - this._tool._tooltip.innerHTML = msg + ""; - this._tool._tooltip.style.width = "165px"; - } else { - - var msg = prefix + "Distance: "; - msg = msg + measureObj.intermediate; - - msg += "
Total: "; - msg += measureObj.total; - - this._tool._tooltip.innerHTML = msg + ""; - this._tool._tooltip.style.width = "auto"; - this._tool._tooltip.style.padding = "10px;"; - - } - } - }, _updateTooltipPosition:function(c){ this._tool._updateTooltip(c); } diff --git a/src/ExportUtil.js b/src/ExportUtil.js index 5fc9bec..a5edbda 100644 --- a/src/ExportUtil.js +++ b/src/ExportUtil.js @@ -14,7 +14,7 @@ define( "dojo/topic", 'dojo/Deferred', 'esri/tasks/PrintTask' - + ], function ( declare, array, @@ -45,7 +45,8 @@ define( var printTask = new PrintTask(); - var w = printTask._getPrintDefinition(map); + // gbs.sjh - second paramater is required at sjapi v3.14, is a PrintTemplate object I think. This is quick fix. + var w = printTask._getPrintDefinition(map, {preserveScale: false}); var operationalLayers = this.getOperationalLayers(w,map); var mapOptions = w.mapOptions; @@ -71,7 +72,7 @@ define( feat.symbol.url = baseUrl + feat.symbol.url; } } - // text symbol, remove all attributes + // text symbol, remove all attributes if (feat.symbol.type === "esriTS") { feat.attributes = {}; } @@ -83,7 +84,7 @@ define( } }); - webmapJson = this.stringify(w); + webmapJson = this.stringify(w); return webmapJson; }, @@ -106,7 +107,3 @@ define( return ExportUtil; }); - - - - diff --git a/src/Widget.js b/src/Widget.js index f252884..13c738e 100644 --- a/src/Widget.js +++ b/src/Widget.js @@ -18,6 +18,8 @@ define([ 'dojo/_base/declare', "dojo/_base/connect", 'dojo/Deferred', + 'dojo/query', + 'dojo/dom-attr', 'dijit/_WidgetsInTemplateMixin', 'jimu/BaseWidget', 'esri/graphic', @@ -64,7 +66,7 @@ define([ './DynamicMeasure', './ExportUtil' ], -function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphic, Point, +function (declare, connect, Deferred, domQuery, domAttr, _WidgetsInTemplateMixin, BaseWidget, Graphic, Point, SimpleMarkerSymbol, Polyline, SimpleLineSymbol, Polygon, SimpleFillSymbol, TextSymbol, Font, esriUnits, webMercatorUtils, geodesicUtils, lang, on, aspect,screenUtils,ScreenPoint, /////////////////// @@ -77,7 +79,7 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi var MoveMenu, RoScMenu, SepMenu, MenuDelete, XYMenu; //////////////////////////// return declare([BaseWidget, _WidgetsInTemplateMixin], { - name: 'AdvancedDraw', + name: 'DrawMeasureWiget', baseClass: 'jimu-widget-draw', postMixInProperties: function () { @@ -98,7 +100,7 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi this._initUnitSelect(); this._initBufferUnitSelect(); this._bindEvents(); - this._addCustomPointSymbology(); + this._addCustomPictureMarkerSymbology(); this._showFooterPanel(); this._setExportImportButtonVisibility(); this._resetButtonStates(); @@ -154,17 +156,16 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi _addBufferTool: function () { var toolDom = domQuery("div.draw-items", this.drawBox.domNode)[0]; var params = {}; - lang.mixin(params, this.config.bufferSettings); params.geomServiceUrl = this.appConfig.geometryService; - this.bufferTool = new Buffer(toolDom, this.map, this.drawBox.drawLayer, params); + this.bufferTool = new Buffer(toolDom, this.map, this.drawBox.drawLayer, this.nls,params); on(this.bufferTool.domNode, 'click', lang.hitch(this, this._onBufferToolClick)); - topic.subscribe('INVALID_BUFFER_REQUEST', lang.hitch(this, function () { + this.invalidBufferTopic =topic.subscribe('INVALID_BUFFER_REQUEST', lang.hitch(this, function () { this._onBufferToolClick({ target: this.bufferTool.domNode }) })); topic.subscribe("LOADING_REQUEST", lang.hitch(this, function () { this._toggleLoading(arguments[0]); })); - topic.subscribe("BUFFER_GRAPHIC_ADDED", lang.hitch(this, function () { + this.bufferAddTopic = topic.subscribe("BUFFER_GRAPHIC_ADDED", lang.hitch(this, function () { this._onBufferToolClick({ target: this.bufferTool.domNode }) if (this.showMeasure.checked) { this._addPolygonMeasure(arguments[0]); @@ -174,10 +175,11 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi _showFooterPanel: function () { domStyle.set(this.footerSection, "display", "block"); }, - _addCustomPointSymbology: function () { - if (this.config.customPointSymbology && this.config.customPointSymbology.length) { - array.forEach(this.config.customPointSymbology, lang.hitch(this, function (symbol) { - this.pointSymChooser.pointSymClassSelect.addOption({ label: symbol.name, value: symbol.file }) + _addCustomPictureMarkerSymbology: function () { + if (this.config.pictureMarkers && this.config.pictureMarkers.length) { + array.forEach(this.config.pictureMarkers, lang.hitch(this, function (symbol) { + var file = symbol.file.replace(/\.json/, ""); + this.pointSymChooser.pointSymClassSelect.addOption({ label: symbol.label, value: file }) })); } }, @@ -226,14 +228,14 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi var symbology = this._getPolygonSymbol(); this.bufferTool.setParams(distance, unit, symbology) }, - + _createBusyIndicator: function () { this._busyLoader = busyUtil.create(this.domNode) }, _updateFileExportImportSettings: function () { if (this.config.importServiceUrl) { this.importServiceUrl = this.config.importServiceUrl; - + } if (this.config.exportServiceUrl) { this.exportServiceUrl = this.config.exportServiceUrl; @@ -271,12 +273,13 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi _uploadMapPackageFile: function () { var deferred = new Deferred(); var form = this.fileUploadForm; - + var corsEnabledServers = esri.config.defaults.io.corsEnabledServers; var domain = this.extractDomain(form.action); if (array.indexOf(corsEnabledServers, domain) == -1) { esri.config.defaults.io.corsEnabledServers.push(domain); } + var uploadDeferred = esri.request({ url: form.action, form: this.fileUploadForm, @@ -366,7 +369,11 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi // all graphics except text are from redline layer var redlineGraphicsLayerConfig = array.filter(results.operationalLayers, function (layer) { var regExp = new RegExp(/graphicsLayer/ig); - return regExp.test(layer.id); + if (regExp.test(layer.id)){ + if(layer.featureCollection && layer.featureCollection.layers.length > 0 ){ + return true; + } + } })[0]; if (!redlineGraphicsLayerConfig || !redlineGraphicsLayerConfig.featureCollection) { @@ -395,8 +402,8 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi } }); - - //now update the main graphic uniqueId to prevent graphics with duplicate unique id + + //now update the main graphic uniqueId to prevent graphics with duplicate unique id //that may come through multiple uploads var aliasGraphics = array.filter(graphicsArray, function (graphic) { @@ -454,9 +461,14 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi this._updateSymbologyOnEditedGraphic(); }))); + this.own(on(this.textSymChooser.inputText, 'keyup', lang.hitch(this, function (symbol) { + this.drawBox.setTextSymbol(symbol); + this._updateSymbologyOnEditedGraphic(); + }))); + //bind unit events this.own(on(this.showMeasure, 'click', lang.hitch(this, this._setMeasureVisibility))); - + // bind Import/Export/Clear button events // no longer applied to import button, due to an issue with IE10 and below. We have switched this to a label // so file upload is initiated by default browser behaviour, not by javascript @@ -559,7 +571,7 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi graphic._graphicsLayer.on("mouse-out", function (evt) { ctxMenuForGraphics.unBindDomNode(evt.graphic.getDojoShape().getNode()); }); - ////////////////////////////////////////// + ////////////////////////////////////////// if (geometry.type && geometry.type === 'extent') { var a = geometry; @@ -587,16 +599,21 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi } } else if (commontype === "point") { graphic.setAttributes({ uniqueId: new Date().getTime() }); + } else if (commontype === 'text') { + this.drawBox.setTextSymbol(this._getTextSymbol()); + graphic.setSymbol(this._getTextSymbol()); } }, _initBufferUnitSelect: function () { - var bufferDistanceUnits = this.config.bufferSettings.bufferDistanceUnits; - array.forEach(bufferDistanceUnits, lang.hitch(this, function (unitInfo) { - var option = { - value: unitInfo.esriConstant, - label: unitInfo.unit - }; - this.bufferUnitsSelect.addOption(option); + var bufferUnits = this.config.bufferUnits; + array.forEach(bufferUnits, lang.hitch(this, function (unitInfo) { + if (unitInfo.enabled) { + var option = { + value: unitInfo.unit, + label: unitInfo.label + }; + this.bufferUnitsSelect.addOption(option); + } })); }, _initUnitSelect: function () { @@ -745,7 +762,7 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi html.setStyle(this.areaMeasure, 'display', 'block'); //html.setStyle(this.distanceMeasure, 'display', 'block'); } - } + } }, _getPointSymbol: function () { return this.pointSymChooser.getSymbol(); @@ -798,7 +815,7 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi this.textSymChooser.textColor.set("value", graphic.symbol.color); this.textSymChooser._updateTextPreview(); } - + }, /////////////////////////////////////////////////////////// onOpen: function () { @@ -806,7 +823,6 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi var map = this.map; function sniffWKID() { if (map.spatialReference.wkid == "102100") { - console.log("Good to go!"); Spat = "geo"; } else { Spatialutils.loadResource().then(function () { @@ -826,11 +842,19 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi sniffWKID(); editToolbar = new Edit(map); - map.on("click", function (evt) { + map.on("click",lang.hitch(this, function (evt) { + if (editToolbar) { + var graphic = editToolbar.getCurrentState().graphic; + if (graphic && graphic.symbol && graphic.symbol.type === "textsymbol") { + this._updateSymbologyEditor(graphic); + this._setDrawDefaultSymbols(); + this._updateSymbologyOnEditedGraphic(); + } + } editToolbar.deactivate(); - }); + })); + - editToolbar.on("activate", lang.hitch(this, function (evt) { this.drawBox.deactivate(); var type = ""; @@ -848,6 +872,8 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi })); + + //1.graphic move editToolbar.on("graphic-move-stop", lang.hitch(this, function (evt) { this._repositionMeasureGraphics(evt); @@ -867,7 +893,7 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi })); - //Creates the right-click menu + //Creates the right-click menu function createGraphicsMenu() { ctxMenuForGraphics = new Menu({}); ctxMenuForGraphics.addChild(new MenuItem({ @@ -966,8 +992,6 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi var fontColor = new Color([0, 0, 0, 1]); var ext = geometry.getExtent(); var center = ext.getCenter(); - - this.dynamicMeasure._calculateDistance(graphic).then(lang.hitch(this, function (distance) { var distUnit = this.distanceUnitSelect.value; var distAbbr = this._getDistanceUnitInfo(distUnit).abbr; @@ -984,10 +1008,9 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi var aliasPointGraphic = new Graphic(center, null, labelAttributes, null); this.drawBox.addGraphic(aliasPointGraphic); - + })); }, - _addPolygonMeasure: function (graphic) { var geometry = graphic.geometry; var a = Font.STYLE_ITALIC; @@ -1108,6 +1131,8 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi this.textSymChooser.destroy(); this.textSymChooser = null; } + this.invalidBufferTopic.remove(); + this.bufferAddTopic.remove(); this.inherited(arguments); }, _importGraphicsFileClicked: function () { @@ -1124,7 +1149,6 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi if (url) { window.location = url; } else { - console.log(resp); this._toggleLoading(false); this._showErrorMessage("error") return; @@ -1190,7 +1214,7 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi }) ); return deferred.promise; - + }, extractDomain:function(url) { var domain; @@ -1213,7 +1237,41 @@ function (declare, connect, Deferred,_WidgetsInTemplateMixin, BaseWidget, Graphi this.viewStack.switchView(null); //start by activating point section this.drawBox.activate("POINT"); - } + this._setVersionTitle(); + }, + + _setVersionTitle: function(){ + var labelNode = this._getLabelNode(this); + var manifestInfo = this.manifest; + var devVersion = manifestInfo.version; + var devWabVersion = manifestInfo.developedAgainst || manifestInfo.wabVersion; + var codeSourcedFrom = manifestInfo.codeSourcedFrom; + var client = manifestInfo.client; + + var title = "Dev version: " + devVersion + "\n"; + title += "Developed/Modified against: WAB" + devWabVersion + "\n"; + title += "Client: " + client + "\n"; + if (codeSourcedFrom) { + title += "Code sourced from: " + codeSourcedFrom + "\n"; + } + + if (labelNode) { + domAttr.set(labelNode, 'title', title); + } + + }, + _getLabelNode: function (widget) { + var labelNode; + if (!(widget.labelNode) && !(widget.titleLabelNode) ) { + if (widget.getParent()) { + labelNode = this._getLabelNode(widget.getParent()); + } + } else { + labelNode = widget.labelNode || widget.titleLabelNode; + } + return labelNode; + + } }); - }); \ No newline at end of file + }); diff --git a/src/config.json b/src/config.json index 35f0d58..5d6b6e0 100644 --- a/src/config.json +++ b/src/config.json @@ -51,35 +51,35 @@ "abbr": "sq yd" } ], - "customPointSymbology": [ - { - "name": "Picture Markers", - "file": "picturemarker" + "pictureMarkers": [ + { + "label": "Picture Markers", + "file": "picturemarker" } ], - "bufferSettings":{ - "mousetip":"Click on a drawing", - "invalidRequestMessage":"Invalid buffer request.", - "bufferDistanceUnits": [ - { - "unit": "Kilometers", - "esriConstant": "UNIT_KILOMETER" - }, - { - "unit": "Meters", - "esriConstant": "UNIT_METER" - }, - { - "unit": "Miles", - "esriConstant": "UNIT_STATUTE_MILE" - }, - { - "unit": "Feet", - "esriConstant": "UNIT_FOOT" - } - ] - }, + "bufferUnits": [ + { + "label": "Kilometers", + "unit": "UNIT_KILOMETER", + "enabled": true + }, + { + "label": "Meters", + "unit": "UNIT_METER", + "enabled": true + }, + { + "label": "Miles", + "unit": "UNIT_STATUTE_MILE", + "enabled": true + }, + { + "label": "Feet", + "unit": "UNIT_FOOT", + "enabled": true + } + ], "includeExportImport":false, - "importServiceUrl":"https://secure.gbs.co.nz/arcgis/rest/services/WDC/ExportGraphics/GPServer/uploads/upload", - "exportServiceUrl":"https://secure.gbs.co.nz/arcgis/rest/services/WDC/ExportGraphics/GPServer/ExportGraphics/execute" + "importServiceUrl": "https://secure.gbs.co.nz/arcgis_anon/rest/services/GPTools/ExportGraphics/GPServer/uploads/upload", + "exportServiceUrl": "https://secure.gbs.co.nz/arcgis_anon/rest/services/GPTools/ExportGraphics/GPServer/ExportGraphics/execute" } \ No newline at end of file diff --git a/src/images/icon.png b/src/images/icon.png index 0e8f02e94599aeff17b1298c67a2bc424f04f82d..7e0386a6c49556be32b53aca89d00f3fe5c56294 100644 GIT binary patch literal 1796 zcmV+f2mAPmP)004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00002 zVoOIv0RM-N%)bBt1|La8K~z}7o!CokRQDCf@iTt#ig|+pL!^ePg}jtT-37>^sR{`g z)JEWtC?$)4N-CjLrje?O2o_b{gr>MvDHV$2iWFEhL|J4J2&*=gx`3n$n#51uZ-@=p z1`PgmF?Ysy?6HlR*;xPoo&WEibH4YS-*qM;LPTjSi66(UXo#;eaep5XCGn%EiKf^c zmm>z8BjY*8aM#DaC)}5WjA~7~bf`DofX(onWA6IcKlS>zC8L)SGFEEVYP~(W>?n|t z@tptZbHKMPbQqsoG&&ifM70*jt&lO-KHb@9l2ejI9q=t7JnWD@UsyaUk&J5XnpGKNWPCbsLv5k-&-_EqFS_ArBto}^SqyuaZ#@~lTD#Uslk z(Bsa%BrTC>)oO(j1NW-z)1}^wQ0dRQowv>y zVVZh9&iai{^f@{lX^BLeW-HSY!d#WIGJAB`9KvjW(BqtSW~$fYf(=SM=8!%|hLXuc z+h%1tQ4zw^-Z5XuSg*_O?BZ0v)ai`Fx?He9c|zJ@94!WP0koyktK~w4O?LXOm- zec(%N18Px3<^i>?Ig_nTe)W+A=t0d!m}R?dCJQg<8C32eWX7val9rBUp-+bZI?V94 zEnd{B=^iBV(QJ0rd9M`I=Fvi+g(}mMzvkMnN7FF1C|a8w(CPda04>z0S0$8K?(3q^ zjvzBZtq$h~$UN+j+rG#)8c?D+|2S9A33gh6p0#? zv>ec5Qqj!Q;C8Mye&EE2&<-O}qD(~|=&>o8Dvjy+cpWkrI`gdL{V-vp`?V%A}Iks5b}nXhe!kJvo`nx(6g}c0bUgOH|6L73@{m ztiyF%3J{p5!L56?gTq+0Dm5yTW;3`pb2aMqm7ff}v7sdLR!znnGxDRU-Y&C~q+M}i zKs2*8y5*GB{o`S1iM&-4O4O(`TMpR2+G(+hWO{blV#)xZZ#ikrkTQdMb+n zde%qU{7k6|wK{bU0=mH+C#)%&wBlARv3=WYH&ZCF!g1}E%1zIXoJ{`eIU4mkVRaFi z;#MvB;UwFnhM`9gc23Xg-Uha^g?0}N{SeW zan?EMMt^ODvEFbC`*ZY#MqSpY2aZtgd25Xos{F&vq3nSWO4T^2I}5Zh!D}wL;gU|z z=0tv_(;iiM|B?MZ>0K`ytJ;^t`zWDIjZ+C}WBuHDS8cN0T_38*zBA5HuiHLViAbfV zR0xl2v|a1SgHX zYaG|>mTNX8GpNp8`#m7JBrEg2c|w?Pr`N63G^}kdmb4SNWV^-22v0cWglFV0neLCe z>@`OS3w-F@=&YJhZiP==cUQZ=TV+nKluS=*GgroPr?rmOstFl0JZqn``gHo2 z2HnnDl)fY@v&XAi`WwjTK0-#hMe6)V59qU_@Pg^;b?Ulbi2|wb*kHd)`kc05UK! zHZ3qQEiyM$FfckWGdeRfD=;xSFfbZJEWH2#03~!qSaf7zbY(hiZ)9m^c>ppnF*YqQ mF)cDTR4_0)Ff%$cGb=DLIxsM69+Uw90000I5Bu5mkkpMA9pPzcgdTOnwTf`N={J5m}+lzsCHO_7PO!R zEoecPMJuI}164yt$PIFVXk7O%JA3#hwctBy$kTk*1koXm-0ks#JZ5VRBIs0bb~FVzE1C+N4NVEof~E$CqGJc9qn(3)d~OG#76&Aj2`sif zMv5ISaS%reFgqH@NWB1$2D74ZD*FP$^(h6+jqVX`?;Jy^v!w#(UEoeatTF`q%zXccolq@0sb<=c_00000NkvXXu0mjfKS7!C diff --git a/src/manifest.json b/src/manifest.json index e7e3485..2cb15bd 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,22 +1,13 @@ { "name": "DrawMeasureWidget", "platform": "HTML", - "version": "1.1", - "wabVersion": "1.1", + "version": "11805", + "client":"GISCO", + "developedAgainst":"1.3", + "wabVersion":"1.3", "author": "Esri R&D Center Beijing", + "codeSourcedFrom":"https://geonet.esri.com/docs/DOC-3256", "description": "", "copyright": "", - "license": "http://www.apache.org/licenses/LICENSE-2.0", - "properties": { - "inPanel": true, - "hasLocale": true, - "hasStyle": true, - "hasConfig": true, - "hasUIFile": true, - "hasSettingPage":false, - "hasSettingUIFile":false, - "hasSettingLocale":false, - "hasSettingStyle":false, - "IsController":false - } + "license": "http://www.apache.org/licenses/LICENSE-2.0" } diff --git a/src/nls/strings.js b/src/nls/strings.js index 5b21438..df934ce 100644 --- a/src/nls/strings.js +++ b/src/nls/strings.js @@ -42,6 +42,8 @@ define({ squareYards: "Square yards", bufferDistance:"Buffer Distance", bufferUnits: "Buffer Units", + bufferMouseTip: "Click on a drawing", + invalidRequestMessage: "Invalid buffer request.", invalidUploadFile: "File type not supported for this operation.Please use map package files (.mpk)", failedUpload: "File upload failed.Please contact the administrator.", failedRetrievingGraphics: "Failed to import graphics." diff --git a/src/setting/Setting.html b/src/setting/Setting.html index b4aad9d..89e8400 100644 --- a/src/setting/Setting.html +++ b/src/setting/Setting.html @@ -1,6 +1,8 @@
-
-