Page MenuHomeIn-Portal Phabricator

D98.id233.diff
No OneTemporary

File Metadata

Created
Mon, Jan 6, 4:31 AM

D98.id233.diff

Index: modules/custom/admin_templates/widgets/widget_edit.tpl
===================================================================
--- modules/custom/admin_templates/widgets/widget_edit.tpl
+++ modules/custom/admin_templates/widgets/widget_edit.tpl
@@ -84,8 +84,9 @@
<inp2:m_RenderElement name="inp_edit_swf_upload" prefix="$prefix" field="Image"/>
<inp2:m_RenderElement name="inp_edit_swf_upload" prefix="$prefix" field="DataFile"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="$prefix" field="Priority" title="la_fld_Order"/>
<inp2:m_RenderElement name="inp_edit_filler"/>
</table>
</div>
-<inp2:m_include t="incs/footer"/>
\ No newline at end of file
+<inp2:m_include t="incs/footer"/>
Index: modules/custom/admin_templates/widgets/widget_list.tpl
===================================================================
--- modules/custom/admin_templates/widgets/widget_list.tpl
+++ modules/custom/admin_templates/widgets/widget_list.tpl
@@ -70,6 +70,23 @@
a_toolbar.AddButton( new ToolBarSeparator('sep2') );
+ a_toolbar.AddButton( new ToolBarButton('move_up', '<inp2:m_phrase label="la_ToolTip_MoveUp" escape="1"/>', function() {
+ submit_event('<inp2:m_Param name="prefix"/>', 'OnMassMoveUp');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarButton('move_down', '<inp2:m_phrase label="la_ToolTip_MoveDown" escape="1"/>', function() {
+ submit_event('<inp2:m_Param name="prefix"/>', 'OnMassMoveDown');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarButton('refresh', '<inp2:m_phrase label="la_ToolTip_RecalculatePriorities" escape="1"/>', function() {
+ submit_event('<inp2:m_Param name="prefix"/>', 'OnRecalculatePriorities');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep3') );
+
a_toolbar.AddButton(
new ToolBarButton(
'export',
@@ -90,7 +107,7 @@
)
);
- a_toolbar.AddButton( new ToolBarSeparator('sep3') );
+ a_toolbar.AddButton( new ToolBarSeparator('sep4') );
a_toolbar.AddButton(
new ToolBarButton(
@@ -134,7 +151,7 @@
<inp2:m_RenderElement name="grid" PrefixSpecial="$prefix" IdField="$id_field" grid="$grid" max_row_height="100"/>
<script type="text/javascript">
- Grids['<inp2:m_Param name="prefix"/>'].SetDependantToolbarButtons( new Array('edit', 'delete', 'approve', 'decline') );
+ Grids['<inp2:m_Param name="prefix"/>'].SetDependantToolbarButtons( new Array('edit', 'delete', 'approve', 'decline', 'move_up', 'move_down') );
</script>
-<inp2:m_include t="incs/footer"/>
\ No newline at end of file
+<inp2:m_include t="incs/footer"/>
Index: modules/custom/install/install_schema.sql
===================================================================
--- modules/custom/install/install_schema.sql
+++ modules/custom/install/install_schema.sql
@@ -12,6 +12,7 @@
BirthTime int(10) unsigned DEFAULT NULL,
Image text,
DataFile text,
+ Priority int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (WidgetId)
);
Index: modules/custom/install/upgrades.sql
===================================================================
--- modules/custom/install/upgrades.sql
+++ modules/custom/install/upgrades.sql
@@ -70,3 +70,6 @@
# ===== v 1.2.1-RC1 =====
# ===== v 1.2.1 =====
+
+# ===== v 1.2.2-B1 =====
+ALTER TABLE Widgets ADD `Priority` INT NOT NULL DEFAULT '0';
Index: modules/custom/units/widgets/widget_eh.php
===================================================================
--- modules/custom/units/widgets/widget_eh.php
+++ modules/custom/units/widgets/widget_eh.php
@@ -18,9 +18,10 @@
{
parent::mapPermissions();
- $permissions = Array (
- 'OnItemBuild' => Array ('self' => true),
- 'OnCustomEvent' => Array ('self' => true),
+ $permissions = array(
+ 'OnItemBuild' => array('self' => true),
+ 'OnRecalculatePriorities' => array('self' => 'add|edit'),
+ 'OnCustomEvent' => array('self' => true),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
@@ -47,6 +48,63 @@
}
/**
+ * Define alternative event processing method names
+ *
+ * @return void
+ */
+ protected function mapEvents()
+ {
+ parent::mapEvents();
+
+ $events_map = array(
+ 'OnMassMoveUp' => 'OnChangePriority',
+ 'OnMassMoveDown' => 'OnChangePriority',
+ );
+
+ $this->eventMethods = array_merge($this->eventMethods, $events_map);
+ }
+
+ /**
+ * Processes OnMassMoveUp, OnMassMoveDown events
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnChangePriority(kEvent $event)
+ {
+ $this->Application->SetVar('priority_prefix', $event->getPrefixSpecial());
+ $event->CallSubEvent('priority:' . $event->Name);
+ }
+
+ /**
+ * Completely recalculates priorities in current category
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnRecalculatePriorities(kEvent $event)
+ {
+ $this->Application->SetVar('priority_prefix', $event->getPrefixSpecial());
+ $event->CallSubEvent('priority:' . $event->Name);
+ }
+
+ /**
+ * [HOOK] Connects to priority unit.
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnModifyPrioritiesConfig(kEvent $event)
+ {
+ $prefixes = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'ProcessPrefixes');
+ $prefixes[] = $event->Prefix;
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'ProcessPrefixes', $prefixes);
+ }
+
+ /**
* Set custom query for the list
*
* @param kEvent $event
@@ -316,4 +374,4 @@
return true;
}
-}
\ No newline at end of file
+}
Index: modules/custom/units/widgets/widgets_config.php
===================================================================
--- modules/custom/units/widgets/widgets_config.php
+++ modules/custom/units/widgets/widgets_config.php
@@ -28,6 +28,19 @@
5 => 'mode',
),
+ 'Hooks' => array(
+ array(
+ 'Mode' => hBEFORE,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'priority',
+ 'HookToSpecial' => '*',
+ 'HookToEvent' => array('OnAfterConfigRead'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '*',
+ 'DoEvent' => 'OnModifyPrioritiesConfig',
+ ),
+ ),
+
// in case, when one method does everything
'RewriteListener' => 'WidgetRewriteListener',
@@ -61,7 +74,7 @@
'widget_list' => Array (
'prefixes' => Array ('widget_List'), 'format' => '#section_label#',
- 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'approve', 'decline', 'export', 'import', 'view', 'dbl-click',),
+ 'toolbar_buttons' => array('new_item', 'edit', 'delete', 'approve', 'decline', 'move_up', 'move_down', 'refresh', 'export', 'import', 'view', 'dbl-click'),
),
'widget_edit' => Array (
@@ -99,8 +112,7 @@
'ListSortings' => Array (
'' => Array (
-// 'ForcedSorting' => Array ('Priority' => 'desc'),
- 'Sorting' => Array ('Title' => 'asc'),
+ 'Sorting' => array('Priority' => 'desc'),
)
),
@@ -196,11 +208,22 @@
'direct_links' => true, // use direct file urls or send files through wrapper (requires mod_mime_magic)
'default' => null
),
+ 'Priority' => array(
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => array(),
+ 'not_null' => 1, 'default' => 0,
+ ),
),
'Grids' => Array (
'Default' => Array (
-// 'Icons' => Array ('default' => 'icon16_custom.gif'),
+ 'Icons' => array(
+ 'default' => 'icon16_item.png',
+ 1 => 'icon16_item.png',
+ 2 => 'icon16_pending.png',
+ 0 => 'icon16_disabled.png',
+ 'module' => 'core',
+ ),
'Fields' => Array (
'WidgetId' => Array ('title' => 'column:la_fld_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
'Title' => Array ('title' => 'column:la_fld_Name', 'data_block' => 'grid_custom_td'),
@@ -214,6 +237,7 @@
'CreatedOn' => Array ('filter_block' => 'grid_date_range_filter'),
'Description' => Array ('filter_block' => 'grid_like_filter'),
'VirtualActionField' => Array ('title' => 'column:la_fld_Action', 'data_block' => 'grid_delete_td'),
+ 'Priority' => array('filter_block' => 'grid_options_filter'),
),
),
),
@@ -222,4 +246,4 @@
'PerPage' => 'Perpage_Widgets',
'ShortListPerPage' => 'Perpage_Widgets_Short',
),*/
-);
\ No newline at end of file
+);

Event Timeline