Skip to content

Commit

Permalink
Remove templates button from rich text setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Morse committed Nov 30, 2018
1 parent 4058f9c commit e43afc6
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 72 deletions.
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"src/javascript/utils/__ts-info-link.js",
"src/javascript/utils/__ts-logger.js",
"src/javascript/utils/__ts-utilities.js",
"src/javascript/RichTextEditorSettingsField.js",
"src/javascript/app.js"
],
"css": [
Expand Down
5 changes: 3 additions & 2 deletions deploy/App-external.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
Ext.define("Rally.technicalservices.InfoLink",{extend:"Rally.ui.dialog.Dialog",alias:"widget.tsinfolink",informationHtml:null,title:"Build Information",defaults:{padding:5,margin:5},closable:!0,draggable:!0,autoShow:!0,width:350,informationalConfig:null,showLog:!1,logger:null,items:[{xtype:"container",itemId:"information"},{xtype:"container",itemId:"button_box"}],initComponent:function(){Ext.id(this);this.title="<span class='icon-help'> </span>"+this.title,this.callParent(arguments)},_generateChecksum:function(t){var i,n=305419896;for(t=(t=(t=t.replace(/var CHECKSUM = .*;/,"")).replace(/var BUILDER = .*;/,"")).replace(/\s/g,""),i=0;i<t.length;i++)n+=t.charCodeAt(i)*i;return n},_checkChecksum:function(t){var i=Ext.create("Deft.Deferred"),n=this;return Ext.Ajax.request({url:document.URL,params:{id:1},success:function(t){if(text=t.responseText,CHECKSUM){var e=n._generateChecksum(text);if(CHECKSUM!==e)return void i.resolve(!1)}i.resolve(!0)}}),i.promise},_addToContainer:function(t){var i=Ext.apply({xtype:"container",height:200,overflowY:!0},this.informationalConfig);t.add(i)},afterRender:function(){var t=Rally.getApp();if(!Ext.isEmpty(this.informationalConfig)){var i=this.down("#information");this._addToContainer(i)}this.showLog&&this.logger&&this.down("#button_box").add({xtype:"rallybutton",text:"Show Log",listeners:{scope:this,click:function(){this.logger.displayLog()}}}),t.isExternal()?this.addDocked({xtype:"container",cls:"build-info",padding:2,dock:"bottom",html:"... Running externally"}):this._checkChecksum(t).then({scope:this,success:function(t){t||this.addDocked({xtype:"container",cls:"build-info",dock:"bottom",padding:2,html:'<span class="icon-warning"> </span>Checksums do not match'})},failure:function(t){console.log("oops:",t)}}),this.callParent(arguments)},beforeRender:function(){if(this.callParent(arguments),this.informationHtml&&this.addDocked({xtype:"component",componentCls:"intro-panel",padding:2,html:this.informationHtml,dock:"bottom"}),this.addDocked({xtype:"container",cls:"build-info",padding:2,dock:"bottom",html:"This app was created by the CA AC Technical Services Team."}),APP_BUILD_DATE){var t=Ext.String.format("Built on: {0} <br/>Built by: {1}",APP_BUILD_DATE,BUILDER);ARTIFACT&&(t=t+"<br/>Source artifact: "+ARTIFACT),this.addDocked({xtype:"container",cls:"build-info",padding:2,dock:"top",html:t})}}});
Ext.define("CArABU.technicalservices.Logger",{saveForLater:!1,saveLines:100,logArray:[],constructor:function(t){Ext.apply(this,t)},setSaveForLater:function(t){this.saveForLater=t},log:function(t){var o="[ "+Ext.util.Format.date(new Date,"Y-m-d H:i:s.u")+" ]",e=[];e=Ext.Array.push(e,[o]),e=Ext.Array.push(e,Ext.Array.slice(arguments,0)),this.saveForLater&&(this.logArray||(this.logArray=[]),this.logArray.push(e.join(" ")),this.logArray.length>this.saveLines&&this.logArray.shift()),window.console&&console.log.apply(console,e)},getLogText:function(){return this.logArray&&0!==this.logArray.length?this.logArray.join("<br/>"):"-- no log --"},displayLog:function(){var t=this.getLogText();this.popup=Ext.create("Rally.ui.dialog.Dialog",{width:Ext.getBody().getWidth()-20,height:Ext.getBody().getHeight()-20,closable:!0,title:"Log",autoShow:!0,layout:"border",defaults:{layout:"fit",width:"50%",border:!1},items:[{region:"center",xtype:"container",html:t,autoScroll:!0}]})}});
Ext.define("TSUtilities",{singleton:!0,loadWsapiRecords:function(e){var r=Ext.create("Deft.Deferred");return Ext.create("Rally.data.wsapi.Store",Ext.Object.merge({model:"Defect",fetch:["ObjectID"]},e)).load({callback:function(e,o,t){t?r.resolve(e):(console.error("Failed: ",o),r.reject("Problem loading: "+o.error.errors.join(". ")))}}),r.promise},loadAStoreWithAPromise:function(e,r){var o=Ext.create("Deft.Deferred");return Ext.create("Rally.data.wsapi.Store",{model:e,fetch:r}).load({callback:function(e,r,t){t?o.resolve(this):(console.error("Failed: ",r),o.reject("Problem loading: "+r.error.errors.join(". ")))}}),o.promise}});
Ext.define("CArABU.app.RichTextApp",{extend:"Rally.app.App",componentCls:"app",defaults:{padding:10},layout:"fit",config:{defaultSettings:{html:"<em>Use the gear to change display text...</em>"}},integrationHeaders:{name:"CArABU.app.TSApp"},launch:function(){this.removeAll();var t=this.getSetting("html");this.add({xtype:"component",html:t,cls:"default-counter"})},getSettingsFields:function(){return[{xtype:"container",margin:"10 70 0 60",html:'<div class="variable-label">Display Text</div>'},{name:"html",flex:1,xtype:"rallyrichtexteditor",margin:"10 70 0 60",fieldLabel:"Informational Text",_createResizer:function(){},resizeable:!1,readyEvent:"afterload",_drawEditor:function(){var t=this.createClosureEditor();this._createResizer(),t.always(function(){if(this.initialLoadFinished=!0,this._lastValue=this.getValue(),this.getGrowToFitContent()){var t=Ext.get(this.closureEditor.field).select("img");t.elements.length>0?Rally.util.Ui.executeCallbackWhenImagesLoaded(t,this._growToFitContent,this):this._growToFitContent()}this._ieClosureFocusWorkaround(),this.fireEvent("load",this),Ext.defer(function(){this.fireEvent("afterload",this)},1,this)},this)}}]},_launchInfo:function(){this.about_dialog&&this.about_dialog.destroy(),this.about_dialog=Ext.create("Rally.technicalservices.InfoLink",{showLog:this.getSetting("saveLog"),logger:this.logger})},isExternal:function(){return void 0===this.getAppId()}});
Ext.define("RichTextEditorSettingsField",{alias:"widget.richtexteditorsettingsfield",extend:"Rally.ui.richtext.RichTextEditor",constructPlugins:function(){return this.plugins=_.reject([this.plugins,"rallyrichtexttemplates"]),this.callParent(arguments)},_createResizer:function(){},_drawEditor:function(){var t=this.createClosureEditor();this._createResizer(),t.always(function(){if(this.initialLoadFinished=!0,this._lastValue=this.getValue(),this.getGrowToFitContent()){var t=Ext.get(this.closureEditor.field).select("img");t.elements.length>0?Rally.util.Ui.executeCallbackWhenImagesLoaded(t,this._growToFitContent,this):this._growToFitContent()}this._ieClosureFocusWorkaround(),this.fireEvent("load",this),Ext.defer(function(){this.fireEvent("afterload",this)},1,this)},this)}});
Ext.define("CArABU.app.RichTextApp",{extend:"Rally.app.App",componentCls:"app",defaults:{padding:10},layout:"fit",config:{defaultSettings:{html:"<em>Use the gear to change display text...</em>"}},integrationHeaders:{name:"CArABU.app.TSApp"},launch:function(){this.removeAll();var t=this.getSetting("html");this.add({xtype:"component",html:t,cls:"default-counter"})},getSettingsFields:function(){return[{xtype:"container",margin:"10 70 0 60",html:'<div class="variable-label">Display Text</div>'},{name:"html",flex:1,xtype:"richtexteditorsettingsfield",margin:"10 70 0 60",fieldLabel:"Informational Text",resizeable:!1,readyEvent:"afterload"}]},_launchInfo:function(){this.about_dialog&&this.about_dialog.destroy(),this.about_dialog=Ext.create("Rally.technicalservices.InfoLink",{showLog:this.getSetting("saveLog"),logger:this.logger})},isExternal:function(){return void 0===this.getAppId()}});

Rally.launchApp('CArABU.app.RichTextApp', {
name:"Rich Text App",
parentRepos:"",
version:"0.2.4"
version:"0.2.6"
});

});
Expand Down
77 changes: 45 additions & 32 deletions deploy/App-uncompressed.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,46 @@
}
});

Ext.define('RichTextEditorSettingsField', {
alias: 'widget.richtexteditorsettingsfield',
extend: 'Rally.ui.richtext.RichTextEditor',

constructPlugins: function() {
this.plugins = _.reject([this.plugins, 'rallyrichtexttemplates']); //we don't want the templates plugin
return this.callParent(arguments);
},

_createResizer: function(){}, //This is an override so that the resizer handle which is hardcoded in the component doesn't hide the last line of the editor.

//This function is an override so that the readyEvent
//is consistently fired async. Otherwise we get weird
//settings panel missing buttons/sizing issues
_drawEditor: function () {
var editorLoadPromise = this.createClosureEditor();
this._createResizer();

editorLoadPromise.always(function () {
this.initialLoadFinished = true;
this._lastValue = this.getValue();

if (this.getGrowToFitContent()) {
var images = Ext.get(this.closureEditor.field).select('img');
if (images.elements.length > 0) {
Rally.util.Ui.executeCallbackWhenImagesLoaded(images, this._growToFitContent, this);
}
else {
this._growToFitContent();
}
}

this._ieClosureFocusWorkaround();
this.fireEvent('load', this);

//This is the only added line
Ext.defer(function() { this.fireEvent('afterload', this); }, 1, this);
}, this);
}
});
Ext.define("CArABU.app.RichTextApp", {
extend: 'Rally.app.App',
componentCls: 'app',
Expand Down Expand Up @@ -347,41 +387,14 @@
},{
name:'html',
flex: 1,
xtype:'rallyrichtexteditor',
xtype:'richtexteditorsettingsfield',
margin: '10 70 0 60',
fieldLabel: 'Informational Text',
_createResizer: function(){}, //This is an override so that the resizer handle which is hardcoded in the component doesn't hide the last line of the editor.
resizeable: false,

readyEvent: 'afterload',
//This function is an override so that the readyEvent
//is consistently fired async. Otherwise we get weird
//settings panel missing buttons/sizing issues
_drawEditor: function () {
var editorLoadPromise = this.createClosureEditor();
this._createResizer();

editorLoadPromise.always(function () {
this.initialLoadFinished = true;
this._lastValue = this.getValue();

if (this.getGrowToFitContent()) {
var images = Ext.get(this.closureEditor.field).select('img');
if (images.elements.length > 0) {
Rally.util.Ui.executeCallbackWhenImagesLoaded(images, this._growToFitContent, this);
}
else {
this._growToFitContent();
}
}

this._ieClosureFocusWorkaround();
this.fireEvent('load', this);

//This is the only added line
Ext.defer(function() { this.fireEvent('afterload', this); }, 1, this);
}, this);
},
//this is important for sizing/layout
//see the RichTextEditorFix for how/why this is fired.
readyEvent: 'afterload'
}];

},
Expand All @@ -404,7 +417,7 @@
Rally.launchApp('CArABU.app.RichTextApp', {
name:"Rich Text App",
parentRepos:"",
version:"0.2.4"
version:"0.2.6"
});

});
Expand Down
5 changes: 3 additions & 2 deletions deploy/App.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
Ext.define("Rally.technicalservices.InfoLink",{extend:"Rally.ui.dialog.Dialog",alias:"widget.tsinfolink",informationHtml:null,title:"Build Information",defaults:{padding:5,margin:5},closable:!0,draggable:!0,autoShow:!0,width:350,informationalConfig:null,showLog:!1,logger:null,items:[{xtype:"container",itemId:"information"},{xtype:"container",itemId:"button_box"}],initComponent:function(){Ext.id(this);this.title="<span class='icon-help'> </span>"+this.title,this.callParent(arguments)},_generateChecksum:function(t){var i,n=305419896;for(t=(t=(t=t.replace(/var CHECKSUM = .*;/,"")).replace(/var BUILDER = .*;/,"")).replace(/\s/g,""),i=0;i<t.length;i++)n+=t.charCodeAt(i)*i;return n},_checkChecksum:function(t){var i=Ext.create("Deft.Deferred"),n=this;return Ext.Ajax.request({url:document.URL,params:{id:1},success:function(t){if(text=t.responseText,CHECKSUM){var e=n._generateChecksum(text);if(CHECKSUM!==e)return void i.resolve(!1)}i.resolve(!0)}}),i.promise},_addToContainer:function(t){var i=Ext.apply({xtype:"container",height:200,overflowY:!0},this.informationalConfig);t.add(i)},afterRender:function(){var t=Rally.getApp();if(!Ext.isEmpty(this.informationalConfig)){var i=this.down("#information");this._addToContainer(i)}this.showLog&&this.logger&&this.down("#button_box").add({xtype:"rallybutton",text:"Show Log",listeners:{scope:this,click:function(){this.logger.displayLog()}}}),t.isExternal()?this.addDocked({xtype:"container",cls:"build-info",padding:2,dock:"bottom",html:"... Running externally"}):this._checkChecksum(t).then({scope:this,success:function(t){t||this.addDocked({xtype:"container",cls:"build-info",dock:"bottom",padding:2,html:'<span class="icon-warning"> </span>Checksums do not match'})},failure:function(t){console.log("oops:",t)}}),this.callParent(arguments)},beforeRender:function(){if(this.callParent(arguments),this.informationHtml&&this.addDocked({xtype:"component",componentCls:"intro-panel",padding:2,html:this.informationHtml,dock:"bottom"}),this.addDocked({xtype:"container",cls:"build-info",padding:2,dock:"bottom",html:"This app was created by the CA AC Technical Services Team."}),APP_BUILD_DATE){var t=Ext.String.format("Built on: {0} <br/>Built by: {1}",APP_BUILD_DATE,BUILDER);ARTIFACT&&(t=t+"<br/>Source artifact: "+ARTIFACT),this.addDocked({xtype:"container",cls:"build-info",padding:2,dock:"top",html:t})}}});
Ext.define("CArABU.technicalservices.Logger",{saveForLater:!1,saveLines:100,logArray:[],constructor:function(t){Ext.apply(this,t)},setSaveForLater:function(t){this.saveForLater=t},log:function(t){var o="[ "+Ext.util.Format.date(new Date,"Y-m-d H:i:s.u")+" ]",e=[];e=Ext.Array.push(e,[o]),e=Ext.Array.push(e,Ext.Array.slice(arguments,0)),this.saveForLater&&(this.logArray||(this.logArray=[]),this.logArray.push(e.join(" ")),this.logArray.length>this.saveLines&&this.logArray.shift()),window.console&&console.log.apply(console,e)},getLogText:function(){return this.logArray&&0!==this.logArray.length?this.logArray.join("<br/>"):"-- no log --"},displayLog:function(){var t=this.getLogText();this.popup=Ext.create("Rally.ui.dialog.Dialog",{width:Ext.getBody().getWidth()-20,height:Ext.getBody().getHeight()-20,closable:!0,title:"Log",autoShow:!0,layout:"border",defaults:{layout:"fit",width:"50%",border:!1},items:[{region:"center",xtype:"container",html:t,autoScroll:!0}]})}});
Ext.define("TSUtilities",{singleton:!0,loadWsapiRecords:function(e){var r=Ext.create("Deft.Deferred");return Ext.create("Rally.data.wsapi.Store",Ext.Object.merge({model:"Defect",fetch:["ObjectID"]},e)).load({callback:function(e,o,t){t?r.resolve(e):(console.error("Failed: ",o),r.reject("Problem loading: "+o.error.errors.join(". ")))}}),r.promise},loadAStoreWithAPromise:function(e,r){var o=Ext.create("Deft.Deferred");return Ext.create("Rally.data.wsapi.Store",{model:e,fetch:r}).load({callback:function(e,r,t){t?o.resolve(this):(console.error("Failed: ",r),o.reject("Problem loading: "+r.error.errors.join(". ")))}}),o.promise}});
Ext.define("CArABU.app.RichTextApp",{extend:"Rally.app.App",componentCls:"app",defaults:{padding:10},layout:"fit",config:{defaultSettings:{html:"<em>Use the gear to change display text...</em>"}},integrationHeaders:{name:"CArABU.app.TSApp"},launch:function(){this.removeAll();var t=this.getSetting("html");this.add({xtype:"component",html:t,cls:"default-counter"})},getSettingsFields:function(){return[{xtype:"container",margin:"10 70 0 60",html:'<div class="variable-label">Display Text</div>'},{name:"html",flex:1,xtype:"rallyrichtexteditor",margin:"10 70 0 60",fieldLabel:"Informational Text",_createResizer:function(){},resizeable:!1,readyEvent:"afterload",_drawEditor:function(){var t=this.createClosureEditor();this._createResizer(),t.always(function(){if(this.initialLoadFinished=!0,this._lastValue=this.getValue(),this.getGrowToFitContent()){var t=Ext.get(this.closureEditor.field).select("img");t.elements.length>0?Rally.util.Ui.executeCallbackWhenImagesLoaded(t,this._growToFitContent,this):this._growToFitContent()}this._ieClosureFocusWorkaround(),this.fireEvent("load",this),Ext.defer(function(){this.fireEvent("afterload",this)},1,this)},this)}}]},_launchInfo:function(){this.about_dialog&&this.about_dialog.destroy(),this.about_dialog=Ext.create("Rally.technicalservices.InfoLink",{showLog:this.getSetting("saveLog"),logger:this.logger})},isExternal:function(){return void 0===this.getAppId()}});
Ext.define("RichTextEditorSettingsField",{alias:"widget.richtexteditorsettingsfield",extend:"Rally.ui.richtext.RichTextEditor",constructPlugins:function(){return this.plugins=_.reject([this.plugins,"rallyrichtexttemplates"]),this.callParent(arguments)},_createResizer:function(){},_drawEditor:function(){var t=this.createClosureEditor();this._createResizer(),t.always(function(){if(this.initialLoadFinished=!0,this._lastValue=this.getValue(),this.getGrowToFitContent()){var t=Ext.get(this.closureEditor.field).select("img");t.elements.length>0?Rally.util.Ui.executeCallbackWhenImagesLoaded(t,this._growToFitContent,this):this._growToFitContent()}this._ieClosureFocusWorkaround(),this.fireEvent("load",this),Ext.defer(function(){this.fireEvent("afterload",this)},1,this)},this)}});
Ext.define("CArABU.app.RichTextApp",{extend:"Rally.app.App",componentCls:"app",defaults:{padding:10},layout:"fit",config:{defaultSettings:{html:"<em>Use the gear to change display text...</em>"}},integrationHeaders:{name:"CArABU.app.TSApp"},launch:function(){this.removeAll();var t=this.getSetting("html");this.add({xtype:"component",html:t,cls:"default-counter"})},getSettingsFields:function(){return[{xtype:"container",margin:"10 70 0 60",html:'<div class="variable-label">Display Text</div>'},{name:"html",flex:1,xtype:"richtexteditorsettingsfield",margin:"10 70 0 60",fieldLabel:"Informational Text",resizeable:!1,readyEvent:"afterload"}]},_launchInfo:function(){this.about_dialog&&this.about_dialog.destroy(),this.about_dialog=Ext.create("Rally.technicalservices.InfoLink",{showLog:this.getSetting("saveLog"),logger:this.logger})},isExternal:function(){return void 0===this.getAppId()}});

Rally.launchApp('CArABU.app.RichTextApp', {
name:"Rich Text App",
parentRepos:"",
version:"0.2.4"
version:"0.2.6"
});

});
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_comment": "This file is used by grunt",
"name": "RichTextApp",
"version": "0.2.4",
"version": "0.2.6",
"dependencies": {},
"devDependencies": {
"grunt": "~1.0.1",
Expand All @@ -10,10 +10,10 @@
"grunt-templater": "git://github.com/rockwood/grunt-templater.git",
"underscore": "1.8.3",
"grunt-prompt": "^1.3.3",
"grunt-contrib-uglify": "0.3.2",
"request": "2.67",
"grunt-contrib-watch": "1.0.0",
"username": "2.1.0",
"grunt-contrib-uglify":"0.3.2",
"request":"2.67",
"grunt-contrib-watch":"1.0.0",
"username":"2.1.0",
"rally-sdk2-test-utils": "0.1.2"
}
}
Loading

0 comments on commit e43afc6

Please sign in to comment.