Skip to content

Commit

Permalink
Enhancements and debug :
Browse files Browse the repository at this point in the history
- export file name
- Font family choice (config fiel and config UI) for text plus
- debug for local storage save problem
- Add nauticals unit
  • Loading branch information
jcornet committed Jul 22, 2015
2 parents 02fb3a0 + 71b0025 commit 5e40bed
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h2 data-dojo-attach-point="editorTitle">${nls.addDrawTitle}</h2>
<span>${nls.fontName}</span>
</td>
<td>
<div data-dojo-attach-point="editorTextPlusPoliceNode" data-dojo-type="dijit/form/Select" class="draw-plus font-name">
<div data-dojo-attach-point="editorTextPlusFontFamilyNode" data-dojo-type="dijit/form/Select" class="draw-plus font-name">
<span value="Arial">Arial</span>
<span value="Helvetica">Helvetica</span>
<span value="Times New Roman">Times New Roman</span>
Expand Down
23 changes: 12 additions & 11 deletions Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ define([
var display = (nb_draws > 0) ? 'block' : 'none';
html.setStyle(this.allActionsNode, 'display', display);
this.tableTH.innerHTML = nb_draws + ' ' + this.nls.draws;

//Save data in local storage
this.saveInLocalStorage();

//Other params
this._editorConfig["graphicCurrent"] = false;
Expand Down Expand Up @@ -360,6 +357,7 @@ define([
on(dom.byId('draw-action-delete--' + i), "click", this.listOnActionClick);
on(dom.byId('draw-action-zoom--' + i), "click", this.listOnActionClick);
}
this.saveInLocalStorage();
},

switch2DrawingGraphics : function (i1, i2) {
Expand Down Expand Up @@ -431,7 +429,7 @@ define([
///////////////////////// SYMBOL EDITOR METHODS ///////////////////////////////////////////////////////////
_editorConfig : {
drawPlus : {
"police" : false,
"FontFamily" : false,
"bold" : false,
"italic" : false,
"underline" : false,
Expand Down Expand Up @@ -521,7 +519,7 @@ define([
this._editorConfig["drawPlus"]["underline"] = (symbol.font.decoration == 'underline');
this._editorConfig["drawPlus"]["placement"]["horizontal"] = symbol.horizontalAlignment;
this._editorConfig["drawPlus"]["placement"]["vertical"] = symbol.verticalAlignment;
this.editorTextPlusPoliceNode.set("value", symbol.font.family);
this.editorTextPlusFontFamilyNode.set("value", symbol.font.family);
this.editorTextPlusAngleNode.set("value", symbol.angle);
this._UTIL__enableClass(this.editorTextPlusBoldNode, 'selected', this._editorConfig["drawPlus"]["bold"]);
this._UTIL__enableClass(this.editorTextPlusItalicNode, 'selected', this._editorConfig["drawPlus"]["italic"]);
Expand Down Expand Up @@ -562,7 +560,7 @@ define([

//Get parameters
var text = this.nameField.value;
var family = this.editorTextPlusPoliceNode.value;
var family = this.editorTextPlusFontFamilyNode.value;
var angle = this.editorTextPlusAngleNode.value;
var weight = this._editorConfig["drawPlus"]["bold"] ? esri.symbol.Font.WEIGHT_BOLD : esri.symbol.Font.WEIGHT_NORMAL;
var style = this._editorConfig["drawPlus"]["italic"] ? esri.symbol.Font.STYLE_ITALIC : esri.symbol.Font.STYLE_NORMAL;
Expand Down Expand Up @@ -1134,7 +1132,7 @@ define([

//Bind draw plus event
this.editorUpdateTextPlus = lang.hitch(this, this.editorUpdateTextPlus);
this.editorTextPlusPoliceNode.on("change", this.editorUpdateTextPlus);
this.editorTextPlusFontFamilyNode.on("change", this.editorUpdateTextPlus);
this.editorTextPlusAngleNode.on("change", this.editorUpdateTextPlus);
on(this.editorTextPlusBoldNode, "click", lang.hitch(this, function (evt) {
this._editorConfig["drawPlus"]["bold"] = !this._editorConfig["drawPlus"]["bold"];
Expand Down Expand Up @@ -1292,6 +1290,9 @@ define([
}, {
unit : 'METERS',
label : this.nls.meters
},{
unit : 'NAUTICAL_MILES',
label : this.nls.nauticals
}, {
unit : 'FEET',
label : this.nls.feet
Expand Down Expand Up @@ -1394,10 +1395,10 @@ define([
//Select central position in UI (text placement)
this._UTIL__enableClass(this._editorTextPlusPlacements[4], 'selected', true);

//Manage availaible polices
if(this.config.drawPlus && this.config.drawPlus.polices){
if(this.config.drawPlus.polices.length > 0){
this.editorTextPlusPoliceNode.set("options", this.config.drawPlus.polices).reset();
//Manage availaible FontFamily
if(this.config.drawPlus && this.config.drawPlus.fontFamilies){
if(this.config.drawPlus.fontFamilies.length > 0){
this.editorTextPlusFontFamilyNode.set("options", this.config.drawPlus.fontFamilies).reset();
}
}

Expand Down
7 changes: 5 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"exportFileName" : "myDrawings.json",
"exportFileName" : "myDrawing.json",
"confirmOnDelete" : true,
"allowImportExport" : true,
"allowLocalStorage" : true,
"localStorageKey" : false,
"drawPlus" : {
"polices" : [
"fontFamilies" : [
{ "label": "Arial", "value": "Arial" },
{ "label": "Helvetica", "value": "Helvetica" },
{ "label": "Times New Roman", "value": "Times New Roman" },
Expand All @@ -21,6 +21,9 @@
}, {
"unit" : "METERS",
"abbr" : "m"
},{
"unit" : "NAUTICAL_MILES",
"abbr" : "nm"
}, {
"unit" : "FEET",
"abbr" : "ft"
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eDraw",
"platform": "HTML",
"version": "1.1.2",
"version": "1.1.3",
"wabVersion": "1.1",
"author": "Esri R&D Center Beijing modified by MAGIS NC",
"description": "Enhanced draw widget for WebApp Builder for Arcgis.",
Expand Down
1 change: 1 addition & 0 deletions nls/fr/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ define(
kilometers: "Kilomètres",
miles: "Miles",
meters: "Mètres",
nauticals: "Milles marins",
feet: "Pieds",
yards: "Yards",
squareKilometers: "Kilomètres carrés",
Expand Down
1 change: 1 addition & 0 deletions nls/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ define({
kilometers: "Kilometers",
miles: "Miles",
meters: "Meters",
nauticals: "Nautical miles",
feet: "Feet",
yards: "Yards",
squareKilometers: "Square kilometers",
Expand Down
11 changes: 10 additions & 1 deletion setting/Setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ul class="settings">
<li>
<span class="input">
<input class="jimu-input" type="text" data-dojo-attach-point="exportFileNameInput" value="${nls.exportFileName}" />
<input class="jimu-input" type="text" data-dojo-attach-point="exportFileNameInput" value="${nls.exportFileNameValue}" />
</span>
<span class="label">${nls.exportFileName}</span>

Expand Down Expand Up @@ -39,6 +39,15 @@

</li>
</ul>

<hr />

<div class="btn-add-section" data-dojo-attach-point="btnAddFontFamily">
<span class="btn-add-icon jimu-float-leading"></span>
<span class="btn-add-label jimu-float-leading">${nls.addFontFamily}</span>
</div>
<div data-dojo-attach-point="textPlusFontFamilyTable" data-dojo-type="jimu/dijit/SimpleTable" data-dojo-props='fields:[{name:"label",title:"${nls.label}","class":"label",type:"text",editable:true,unique:true},{name:"value",title:"${nls.value}","class":"value",type:"text",editable:true,unique:true},{name:"actions",title:"${nls.actions}","class":"actions",type:"actions",actions:["up","down","delete"]}]'></div>

<hr />

<div class="query-setting-content" data-dojo-attach-point="content">
Expand Down
51 changes: 48 additions & 3 deletions setting/Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ define([
label: this.nls.meters,
abbr: this.nls.metersAbbreviation||'m',
conversion: jimuUtils.localizeNumber(1)
}, {
value: 'NAUTICAL_MILES',
label: this.nls.nauticals,
abbr: this.nls.nauticalsAbbreviation||'nm',
conversion: jimuUtils.localizeNumber(0.00053957, {places: 7})
}, {
value: 'FEET',
label: this.nls.feet,
Expand Down Expand Up @@ -114,6 +119,7 @@ define([
this.inherited(arguments);
this.own(on(this.btnAddDistance,'click',lang.hitch(this,this._addDistance)));
this.own(on(this.btnAddArea,'click',lang.hitch(this,this._addArea)));
this.own(on(this.btnAddFontFamily,'click',lang.hitch(this,this._addFontFamily)));
this.own(on(this.distanceTable,'row-delete',lang.hitch(this,function(tr){
if(tr.select){
tr.select.destroy();
Expand Down Expand Up @@ -151,12 +157,32 @@ define([
this.config = config;
this._setDistanceTable(this.config.distanceUnits);
this._setAreaTable(this.config.areaUnits);
this._setTextPlusFontFamilyTable(this.config);

this.exportFileNameInput.value = (config.exportFileName) ? config.exportFileName : this.nls.exportFileName;
this.confirmOnDeleteInput.checked = (config.confirmOnDelete) ? true : false;
this.allowImportExportInput.checked = (config.allowImportExport) ? true : false;
this.allowLocalStorageInput.checked = (config.allowLocalStorage) ? true : false;
this.localStorageKeyInput.value = (config.localStorageKey) ? config.localStorageKey : '';

//Text plus FontFamily
this._setTextPlusFontFamilyTable(config);
},

_setTextPlusFontFamilyTable:function(config){
var options =
(config.drawPlus && config.drawPlus.fontFamilies && config.drawPlus.fontFamilies.length > 0)
? config.drawPlus.fontFamilies
: [
{ "label": "Arial", "value": "Arial" },
{ "label": "Helvetica", "value": "Helvetica" },
{ "label": "Times New Roman", "value": "Times New Roman" },
{ "label": "Courier New", "value": "Courier New" }
];

this.textPlusFontFamilyTable.clear();
for(var i in options)
this.textPlusFontFamilyTable.addRow(options[i]);
},

_setDistanceTable:function(distanceUnits){
Expand Down Expand Up @@ -197,8 +223,19 @@ define([
config.allowLocalStorage = this.allowLocalStorageInput.checked;
var key = this.localStorageKeyInput.value.trim();
config.localStorageKey = (key=="") ? false : key;

return config;

if(!config["drawPlus"])
config["drawPlus"] = {};
var FontFamilyOptions = array.map(this.textPlusFontFamilyTable.getRows(),lang.hitch(this,function(tr){
var data = this.textPlusFontFamilyTable.getRowData(tr);
return {
"value":data.value,
"label":data.label
}
}));
config["drawPlus"]["fontFamilies"] = FontFamilyOptions;

return config;
},

_getDistanceConfig:function(){
Expand Down Expand Up @@ -265,7 +302,15 @@ define([
}
return result;
},


_addFontFamily:function(){
console.log("Add font family");
var data = {"label": "New font family", "value": "New font family" };
var result = this.textPlusFontFamilyTable.addRow(data);
if(result)
this.textPlusFontFamilyTable.editRow(result.tr, data);
},

_addDistance:function(){
var notUsedValues = this._getNotUsedDistanceUnitValues();
if(notUsedValues.length === 0){
Expand Down
7 changes: 6 additions & 1 deletion setting/nls/fr/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
({
addDistance: "Ajouter une unité de longueur",
addArea: "Ajouter une unité de surface",
addFontFamily: "Ajouter une police de caractères",
label: "Etiquette",
value: "Valeur",
abbr: "Abréviation",
conversion: "Conversion",
actions: "Actions",
Expand All @@ -11,6 +13,8 @@
kilometers: "Kilomètres",
miles: "Miles",
meters: "Mètres",
meters: "Mètres",
nauticals: "Milles marins",
feet: "Pieds",
yards: "Yards",
squareKilometers: "Kilomètres carrés",
Expand All @@ -27,6 +31,7 @@
allowLocalStorageLabel:"Utiliser local storage",
localStorageKeyLabel:"Clé Local storage",
localStorageKeyInfo:"Si vide, toutes les applications partageront le même storage. Sinon, les applications avec la même clé partageront le même storage.",
exportFileName:"mesDessins.json",
exportFileName:"Nom du fichier exporté",
exportFileNameValue:"mesDessins.json"
})
);
6 changes: 5 additions & 1 deletion setting/nls/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ define({
root: ({
addDistance: "Add Length Unit",
addArea: "Add Area Unit",
addFontFamily: "Add a font family",
label: "Label",
value: "Value",
abbr: "Abbreviation",
conversion: "Conversion",
actions: "Actions",
Expand All @@ -11,6 +13,7 @@ define({
kilometers: "Kilometers",
miles: "Miles",
meters: "Meters",
nauticals: "Nautical miles",
feet: "Feet",
yards: "Yards",
squareKilometers: "Square kilometers",
Expand All @@ -27,7 +30,8 @@ define({
allowLocalStorageLabel:"Use local storage ?",
localStorageKeyLabel:"Local storage key",
localStorageKeyInfo:"If not empty, applications with same key (and same server) will share the same storage. If empty, all will share same storage.",
exportFileName:"myDrawings.json"
exportFileName:"Export file name",
exportFileNameValue:"myDrawing.json"
}),
"ar": 1,
"cs": 1,
Expand Down

0 comments on commit 5e40bed

Please sign in to comment.