New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress between Stage3 to Stage4 #3

Closed
wants to merge 2 commits into
base: stage3
from
Jump to file or symbol
Failed to load files and symbols.
+77 −27
Diff settings

Always

Just for now

Copy path View file
@@ -25,7 +25,7 @@ Testing.panel.Home = function(config) {
,border: false
,bodyCssClass: 'panel-desc'
}, {
xtype: 'modx-tree-menu'
xtype: 'testing-tree-categories'
,cls: 'main-wrapper'
,preventRender: true
}]
@@ -1,7 +1,7 @@
/**
* This is the part of the code the creates the actual tree by extending MODX.tree.Tree
*/
MODx.tree.Menu = function(config) {
Testing.tree.Categories = function(config) {
config = config || {};
Ext.applyIf(config,{
root_id: null
@@ -23,9 +23,9 @@ MODx.tree.Menu = function(config) {
,scope: this
}]
});
MODx.tree.Menu.superclass.constructor.call(this,config);
Testing.tree.Categories.superclass.constructor.call(this,config);
};
Ext.extend(MODx.tree.Menu, MODx.tree.Tree, {
Ext.extend(Testing.tree.Categories, MODx.tree.Tree, {
windows: {}
,createCategory: function(n,e) {
@@ -110,7 +110,7 @@ Ext.extend(MODx.tree.Menu, MODx.tree.Tree, {
return m;
}
});
Ext.reg('modx-tree-menu',MODx.tree.Menu);
Ext.reg('testing-tree-categories', Testing.tree.Categories);
/**
* This code creates the popup window that allows us to create new categories
@@ -120,12 +120,12 @@ Testing.window.CreateCategory = function(config) {
Ext.applyIf(config, {
title: _('testing.category_create')
,url: MODx.config.connector_url
,action: 'system/menu/create'
,url: Testing.config.connectorUrl
,action: 'mgr/create'
,fields: [{
fieldLabel: _('testing.parent')
,name: 'parent'
,xtype: 'modx-combo-menu'
,xtype: 'testing-combo-categories'
,anchor: '100%'
},{
fieldLabel: _('testing.name')
@@ -162,32 +162,27 @@ Ext.extend(MODx.window.UpdateMenu,MODx.window.CreateCategory);
Ext.reg('modx-window-menu-update',MODx.window.UpdateMenu);
/**
* Displays a dropdown of modMenus
*
* @class MODx.combo.Menu
* @extends MODx.combo.ComboBox
* @param {Object} config An object of options.
* @xtype modx-combo-menu
* This code creates the combobox/dropdown menu for selecting
* parent categories.
*/
MODx.combo.Menu = function(config) {
Testing.combo.Categories = function(config) {
config = config || {};
Ext.applyIf(config,{
name: 'menu'
,hiddenName: 'menu'
,url: MODx.config.connector_url
hiddenName: 'parent'
,url: Testing.config.connectorUrl
,baseParams: {
action: 'system/menu/getlist'
action: 'mgr/getParents'
,combo: true
,limit: 0
,showNone: true
}
,fields: ['text','text_lex']
,displayField: 'text_lex'
,valueField: 'text'
// ,listWidth: 300
,fields: ['id','name']
,displayField: 'name'
,valueField: 'id'
,editable: false
,emptyText: _('testing.no_parents')
});
MODx.combo.Menu.superclass.constructor.call(this,config);
Testing.combo.Categories.superclass.constructor.call(this, config);
};
Ext.extend(MODx.combo.Menu,MODx.combo.ComboBox);
Ext.reg('modx-combo-menu',MODx.combo.Menu);
Ext.extend(Testing.combo.Categories, MODx.combo.ComboBox);
Ext.reg('testing-combo-categories', Testing.combo.Categories);
@@ -4,4 +4,5 @@
$_lang['testing.desc'] = 'Description';
$_lang['testing.category_create'] = 'Create new category';
$_lang['testing.parent'] = 'Parent category';
$_lang['testing.name'] = 'Category name';
$_lang['testing.name'] = 'Category name';
$_lang['testing.no_parents'] = 'No parents';
@@ -0,0 +1,38 @@
<?php
class TestingCategoryCreateProcessor extends modProcessor {
public $classKey = 'WhoppCategory';
public $languageTopics = array('whopp:default');
public $objectType = 'whopp.category';
public function process() {
// Parent
$parent = null;
if (is_numeric($this->getProperty('parent'))) {
$parent = $this->getProperty('parent');
}
// Menu index
$menu_index = 0;
$c = $this->modx->newQuery('TestingCategory');
$c->where([
'parent' => $parent
]);
$c->sortby('menuindex', 'DESC');
$c->limit(1);
$last_menu_index_object = $this->modx->getObject('TestingCategory', $c);
if ($last_menu_index_object) {
$menu_index = $last_menu_index_object->get('menuindex') + 1;
}
// Create object
$obj = $this->modx->newObject('TestingCategory');
$obj->set('name', $this->getProperty('name'));
$obj->set('parent', $parent);
$obj->set('menuindex', $menu_index);
$obj->save();
return $this->success();
}
}
return 'TestingCategoryCreateProcessor';
@@ -0,0 +1,16 @@
<?php
class TestingCategoryGetParentsProcessor extends modObjectGetListProcessor {
public $classKey = 'TestingCategory';
public $languageTopics = array('testing:default');
public $objectType = 'testing.category';
public $defaultSortField = 'menuindex';
public function prepareQueryBeforeCount(xPDOQuery $c) {
$c->where([
'parent' => null
]);
return parent::prepareQueryBeforeCount($c);
}
}
return 'TestingCategoryGetParentsProcessor';
ProTip! Use n and p to navigate between commits in a pull request.