Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:ColdTrick/widget_manager.git
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Oct 6, 2021
2 parents 8af3269 + 60dc66b commit 3c4c3c1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 40 deletions.
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,7 @@ Features
- Adding widgets from a lightbox
- Index widgets (with a few different layouts)
- Group widgets (instead of group profile modules)
- Forcing of widget (incl positioning) on profile/dashboard (also later!)
- Option to globally hide a specific widgettype (will even hide widget already placed on profile/dashboard)
- Create group default widgets
- Create extra pages with a widget layout

Info about the fix mechanisme for Default Widgets
-------------------------------------------------

Fixed widgets always

- Appear on top of other widgets
- Can not be removed or edited or dragged by a user
- Maintain a relation to their default widget, so if the default widgets changes, all user widgets also change!
- New fixed widgets will also be added to existing users

You can fix widgets on a dashboard or profile page. Fixing widgets can be done by clicking on the pin in the widget header. Only default widgets added when widget manager is enabled will have the option to fix. This is because a special attribute will be set on the default widget to keep a relation to the widget when cloning it to the user profile or dashboard. If you do not see the pin, remove the widget and add it again.

A user can always add his or hers own widgets. They will always be added below the last fixed widget in the destination column.

1 change: 1 addition & 0 deletions classes/ColdTrick/WidgetManager/CollapsedState.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ protected function getCollapsedCache($user_guid) {
$rels = elgg_get_relationships([
'relationship_guid' => $user_guid,
'relationship' => ['widget_state_collapsed', 'widget_state_open'],
'limit' => false,
]);

foreach ($rels as $rel) {
Expand Down
7 changes: 6 additions & 1 deletion classes/ColdTrick/WidgetManager/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public static function implodeSettings(\Elgg\Hook $hook) {
return;
}

return implode(',', $hook->getValue());
$current_value = $hook->getValue();
if (!is_array($current_value)) {
return;
}

return implode(',', $current_value);
}
}
23 changes: 0 additions & 23 deletions views/default/js/widget_manager/add_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,4 @@ define(['jquery', 'elgg', 'elgg/Ajax', 'elgg/widgets'], function($, elgg, Ajax,
}).show();
}
});

$(document).ajaxSuccess(function (e, xhr, settings) {
if (settings.url === elgg.normalize_url('/action/widgets/add')) {
// move new widget to a new position (after fixed widgets) if needed
if ($(this).find('.elgg-widgets > .elgg-state-fixed').size() > 0) {
var $widget = $(this).find('.elgg-module-widget:first');
$widget.insertAfter($(this).find('.elgg-widgets > .elgg-state-fixed:last'));

// first item is the recently moved widget, because fixed widgets are not part of the sortable
var index = $(this).find('.elgg-module-widget').index($widget);
var guidString = $widget.attr('id');
guidString = guidString.substr(guidString.indexOf('elgg-widget-') + "elgg-widget-".length);

ajax.action('widgets/move', {
data: {
widget_guid: guidString,
column: 1,
position: index
}
});
}
}
});
});
4 changes: 3 additions & 1 deletion views/default/object/widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
$can_edit = $widget->canEdit();

$widget_class = elgg_extract_class($vars, $widget_instance);
$widget_class[] = $can_edit ? 'elgg-state-draggable' : 'elgg-state-fixed';
if ($can_edit) {
$widget_class[] = 'elgg-state-draggable';
}

if ($widget->widget_manager_custom_class) {
$widget_class[] = $widget->widget_manager_custom_class; // optional custom class for this widget
Expand Down

0 comments on commit 3c4c3c1

Please sign in to comment.