Skip to content

Commit 27e02d9

Browse files
author
Bert Oost
committed
Added duplicate feature to the sets
1 parent 79c5d34 commit 27e02d9

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

assets/components/quickstartbuttons/js/mgr/widgets/sets.grid.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ Ext.extend(QuickstartButtons.grid.Sets, MODx.grid.Grid, {
8686
var m = [{
8787
text: _('quickstartbuttons.sets.update')
8888
,handler: this.updateSet
89+
},{
90+
text: _('quickstartbuttons.sets.duplicate')
91+
,handler: this.duplicateSet
8992
},'-',{
9093
text: _('quickstartbuttons.sets.remove')
9194
,handler: this.removeSet
@@ -110,6 +113,21 @@ Ext.extend(QuickstartButtons.grid.Sets, MODx.grid.Grid, {
110113
Ext.isSafari ? w.setPosition(null,30) : w.center();
111114
}, this);
112115
}
116+
,duplicateSet: function(btn, e) {
117+
MODx.Ajax.request({
118+
url: QuickstartButtons.config.connector_url
119+
,params: {
120+
action: 'mgr/sets/duplicate'
121+
,id: this.menu.record.id
122+
}
123+
,listeners: {
124+
'success':{ fn: function() {
125+
this.refresh();
126+
}
127+
,scope:this }
128+
}
129+
});
130+
}
113131
,removeSet: function(btn, e) {
114132
MODx.msg.confirm({
115133
title: _('quickstartbuttons.sets.remove'),

core/components/quickstartbuttons/lexicon/en/default.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
$_lang['quickstartbuttons.sets.buttonsperrow.five'] = "Five buttons";
2525

2626
$_lang['quickstartbuttons.sets.update'] = "Update set";
27+
$_lang['quickstartbuttons.sets.duplicate'] = "Duplicate set";
2728
$_lang['quickstartbuttons.sets.remove'] = "Remove set";
2829
$_lang['quickstartbuttons.sets.remove_confirm'] = "Are you sure you want to remove this set and it's buttons? This is irreversible!";
2930

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
class QuickstartButtonsDuplicateSetProcessor extends modObjectDuplicateProcessor {
4+
public $classKey = 'qsbSet';
5+
public $languageTopics = array('quickstartbuttons:default');
6+
public $objectType = 'quickstartbuttons.qsbset';
7+
8+
public function afterSave() {
9+
10+
$buttons = $this->object->getMany('Button');
11+
12+
/** @var qsbButton $button */
13+
foreach($buttons as $button) {
14+
$buttonArray = $button->toArray();
15+
unset($buttonArray['id']);
16+
17+
/** @var qsbButton $newButton */
18+
$newButton = $this->modx->newObject('qsbButton');
19+
$newButton->fromArray($buttonArray);
20+
$newButton->set('set', $this->newObject->get('id'));
21+
$newButton->save();
22+
}
23+
return parent::afterSave();
24+
}
25+
}
26+
27+
return 'QuickstartButtonsDuplicateSetProcessor';

0 commit comments

Comments
 (0)