Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/119' into develop
Browse files Browse the repository at this point in the history
* origin/pr/119:
  Updated save duplication
  Updated view/close buttons to work correctly with the overriding buttons from ExtJs
  • Loading branch information
theboxer committed Apr 14, 2015
2 parents 3451c98 + d6d6e3f commit a44ab34
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
53 changes: 33 additions & 20 deletions assets/components/articles/js/article/update.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ Articles.page.UpdateArticle = function(config) {
};
Ext.extend(Articles.page.UpdateArticle,MODx.page.UpdateResource,{
doesButtonExist: function(btnArray, lexiconKey) {
var exists = false;
var exists = false, _k = 0;
btnArray.map(function(item) {
if(lexiconKey == item.text) exists = true;
if(lexiconKey == item.text) exists = _k;
_k++;
});
return exists;
}
,getButtons: function(cfg) {
var btns = [];
if (cfg.canSave == 1 && !this.doesButtonExist(btns, _('save'))) {
var btns = MODx.page.UpdateResource.prototype.getButtons(cfg); //[];

if (cfg.canSave == 1 && this.doesButtonExist(btns, _('save') === false)) {
btns.push({
process: (MODx.config.connector_url) ? 'resource/update' : 'update'
,text: _('save')
Expand Down Expand Up @@ -55,24 +57,35 @@ Ext.extend(Articles.page.UpdateArticle,MODx.page.UpdateResource,{
});
btns.push('-');
}
if(!this.doesButtonExist(btns, _('view'))) {
btns.push({
process: 'preview'
,text: _('view')
,handler: this.preview
,scope: this
});
btns.push('-');

var _view = {
process: 'preview'
,text: _('view')
,handler: this.preview
,scope: this
}, _idx = this.doesButtonExist(btns, _('view'));

if(!_idx) {
btns.push(_view);
btns.push('-');
} else {
btns.splice(_idx,1, _view);
}
if(!this.doesButtonExist(btns, _('cancel'))) {
btns.push({
process: 'cancel'
,text: _('cancel')
,handler: this.cancel
,scope: this
});
btns.push('-');

var _cnl = {
process: 'cancel'
,text: _('cancel')
,handler: this.cancel
,scope: this
}, _idx = this.doesButtonExist(btns, _('cancel'));

if(!_idx) {
btns.push(_cnl);
btns.push('-');
} else {
btns.splice(_idx,1, _cnl);
}

if(!this.doesButtonExist(btns, _('help_ex'))) {
btns.push({
text: _('help_ex')
Expand Down
1 change: 1 addition & 0 deletions core/components/articles/docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Changelog for Articles.

- Updated view/close buttons to work correctly with the overriding

Articles 1.7.10
===============================
Expand Down

0 comments on commit a44ab34

Please sign in to comment.