Skip to content

Add option to customize options given when creating the add-widget modal #316

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions CODESCRATCH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Codescratch changes

1. Bug fix if `adfWidgetModalOptions` was undefined.
2. Adding `adfDashboardStructureChange` event.
3. Adding `Edit` and `Save` text to title icons.
4. Adding title link option so that you can link somewhere in the title.
89 changes: 48 additions & 41 deletions dist/angular-dashboard-framework-tpls.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ angular.module('adf', ['adf.provider', 'adf.locale', 'ui.bootstrap'])
angular.module("adf").run(["$templateCache", function($templateCache) {$templateCache.put("../src/templates/dashboard-column.html","<div adf-id={{column.cid}} class=column ng-class=column.styleClass ng-model=column.widgets> <adf-widget ng-repeat=\"definition in column.widgets\" adf-model=adfModel definition=definition column=column edit-mode=editMode options=options widget-state=widgetState> </adf-widget></div> ");
$templateCache.put("../src/templates/dashboard-edit.html","<div class=modal-header> <button type=button class=close ng-click=closeDialog() aria-hidden=true>&times;</button> <h4 class=modal-title ng-bind=\"translate(\'ADF_COMMON_EDIT_DASHBOARD\')\">Edit Dashboard</h4> </div> <div class=modal-body> <form role=form> <div class=form-group> <label for=dashboardTitle ng-bind=\"translate(\'ADF_COMMON_TITLE\')\">Title</label> <input type=text class=form-control id=dashboardTitle ng-model=copy.title required> </div> <div class=form-group> <label ng-bind=\"translate(\'ADF_EDIT_DASHBOARD_STRUCTURE_LABEL\')\">Structure</label> <div class=row ng-init=\"splitted = split(structures, 3)\"> <div class=col-lg-4 ng-repeat=\"structureColumn in splitted\"> <div class=radio ng-repeat=\"(key, structure) in structureColumn\"> <div class=row> <div class=col-sm-2> <label> <input type=radio value={{key}} ng-model=model.structure ng-change=\"changeStructure(key, structure)\"> </label> </div> <div class=col-sm-9 ng-click=\"changeStructure(key, structure)\"> <adf-structure-preview name=key structure=structure selected=\"model.structure == key\"> </adf-structure-preview> </div> </div> </div> </div> </div> </div> </form> </div> <div class=modal-footer> <button type=button class=\"btn btn-primary\" ng-click=closeDialog() ng-bind=\"translate(\'ADF_COMMON_CLOSE\')\">Close</button> </div> ");
$templateCache.put("../src/templates/dashboard-row.html","<div class=row ng-class=row.styleClass ng-style=row.style> </div> ");
$templateCache.put("../src/templates/dashboard-title.html","<h1> {{model.title}} <span style=\"font-size: 16px\" class=pull-right> <a href ng-if=editMode title=\"{{ translate(\'ADF_DASHBOARD_TITLE_TOOLTIP_ADD\') }}\" ng-click=addWidgetDialog()> <i class=\"glyphicon glyphicon-plus-sign\"></i> </a> <a href ng-if=editMode title=\"{{ translate(\'ADF_COMMON_EDIT_DASHBOARD\') }}\" ng-click=editDashboardDialog()> <i class=\"glyphicon glyphicon-cog\"></i> </a> <a href ng-if=options.editable title=\"{{editMode ? translate(\'ADF_DASHBOARD_TITLE_TOOLTIP_SAVE\') : translate(\'ADF_DASHBOARD_TITLE_TOOLTIP_EDIT_MODE\') }}\" ng-click=toggleEditMode()> <i class=glyphicon x-ng-class=\"{\'glyphicon-edit\' : !editMode, \'glyphicon-save\' : editMode}\"></i> </a> <a href ng-if=editMode title=\"{{ translate(\'ADF_DASHBOARD_TITLE_TOOLTIP_UNDO\') }}\" ng-click=cancelEditMode()> <i class=\"glyphicon glyphicon-repeat adf-flip\"></i> </a> </span> </h1> ");
$templateCache.put("../src/templates/dashboard-title.html","<h1> {{model.title}} <a ng-if=model.titleLink ng-href={{model.titleLink}} target=_blank> <small title=\"Open dashboard in separate tab\"><i class=\"glyphicon glyphicon-new-window\"></i></small> </a> <span style=\"font-size: 16px\" class=pull-right> <a href ng-if=editMode title=\"{{ translate(\'ADF_DASHBOARD_TITLE_TOOLTIP_ADD\') }}\" ng-click=addWidgetDialog()> <i class=\"glyphicon glyphicon-plus-sign\"></i> </a> <a href ng-if=editMode title=\"{{ translate(\'ADF_COMMON_EDIT_DASHBOARD\') }}\" ng-click=editDashboardDialog()> <i class=\"glyphicon glyphicon-cog\"></i> </a> <a href ng-if=options.editable title=\"{{editMode ? translate(\'ADF_DASHBOARD_TITLE_TOOLTIP_SAVE\') : translate(\'ADF_DASHBOARD_TITLE_TOOLTIP_EDIT_MODE\') }}\" ng-click=toggleEditMode()> <i class=glyphicon x-ng-class=\"{\'glyphicon-edit\' : !editMode, \'glyphicon-save\' : editMode}\">{{!editMode ? \'Edit\' : \'Save\' }}</i> </a> <a href ng-if=editMode title=\"{{ translate(\'ADF_DASHBOARD_TITLE_TOOLTIP_UNDO\') }}\" ng-click=cancelEditMode()> <i class=\"glyphicon glyphicon-repeat adf-flip\"></i> </a> </span> </h1> ");
$templateCache.put("../src/templates/dashboard.html","<div class=dashboard-container> <div ng-include src=model.titleTemplateUrl></div> <div class=dashboard x-ng-class=\"{\'edit\' : editMode}\"> <adf-dashboard-row row=row adf-model=model options=options ng-repeat=\"row in model.rows\" edit-mode=editMode continuous-edit-mode=continuousEditMode> </adf-dashboard-row></div> </div> ");
$templateCache.put("../src/templates/structure-preview.html","<div class=structure-preview ng-class=\"{selected: selected}\"> <h4>{{name}}</h4> <adf-dashboard-row ng-repeat=\"row in preview.rows\" row=row> </adf-dashboard-row></div> ");
$templateCache.put("../src/templates/widget-add.html","<div class=modal-header> <button type=button class=close ng-click=closeDialog() aria-hidden=true>&times;</button> <h4 class=modal-title ng-bind=\"translate(\'ADF_WIDGET_ADD_HEADER\')\">Add new widget</h4> </div> <div class=modal-body> <div ng-if=createCategories> <uib-accordion ng-init=\"categorized = createCategories(widgets)\"> <uib-accordion-group heading={{category.name}} ng-repeat=\"category in categorized | adfOrderByObjectKey: \'name\'\"> <dl class=dl-horizontal> <dt ng-repeat-start=\"widget in category.widgets | adfOrderByObjectKey: \'key\'\"> <a href ng-click=addWidget(widget.key)> {{widget.title}} </a> </dt> <dd ng-repeat-end ng-if=widget.description> {{widget.description}} </dd> </dl> </uib-accordion-group> </uib-accordion> </div> <div style=\"display: inline-block;\" ng-if=!createCategories> <dl class=dl-horizontal> <dt ng-repeat-start=\"widget in widgets | adfOrderByObjectKey: \'key\'\"> <a href ng-click=addWidget(widget.key)> {{widget.title}} </a> </dt> <dd ng-repeat-end ng-if=widget.description> {{widget.description}} </dd> </dl> </div> </div> <div class=modal-footer> <button type=button class=\"btn btn-primary\" ng-click=closeDialog() ng-bind=\"translate(\'ADF_COMMON_CLOSE\')\">Close</button> </div> ");
Expand Down Expand Up @@ -458,6 +458,46 @@ angular.module('adf')
}
}]);

/*
* The MIT License
*
* Copyright (c) 2015, Sebastian Sdorra
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


/* global angular */
angular.module('adf')
.filter('adfOrderByObjectKey', ["$filter", function($filter) {


return function(item, key){
var array = [];
angular.forEach(item, function(value, objectKey){
value[key] = objectKey;
array.push(value);
});
return $filter('orderBy')(array, key);
};
}]);

/*
* The MIT License
*
Expand Down Expand Up @@ -1012,6 +1052,7 @@ angular.module('adf')
* @param {boolean=} enableConfirmDelete true to ask before remove an widget from the dashboard.
* @param {string=} structure the default structure of the dashboard.
* @param {object=} adfModel model object of the dashboard.
* @param {object=} adfAddWidgetModalOptions options to provide to the add-widget modal
* @param {function=} adfWidgetFilter function to filter widgets on the add dialog.
* @param {boolean=} continuousEditMode enable continuous edit mode, to fire add/change/remove
* events during edit mode not reset it if edit mode is exited.
Expand All @@ -1036,6 +1077,7 @@ angular.module('adf')
continuousEditMode: '=',
maximizable: '@',
adfModel: '=',
adfAddWidgetModalOptions: '=',
adfWidgetFilter: '=',
categories: '@'
},
Expand Down Expand Up @@ -1180,6 +1222,7 @@ angular.module('adf')
if (model.structure !== name){
model.structure = name;
}
$rootScope.$broadcast('adfDashboardStructureChange');
};
editDashboardScope.closeDialog = function(){
// copy the new title back to the model
Expand Down Expand Up @@ -1227,6 +1270,10 @@ angular.module('adf')
backdrop: 'static'
};

if (angular.isDefined($scope.adfAddWidgetModalOptions)) {
opts = angular.merge(opts, $scope.adfAddWidgetModalOptions);
}

var instance = $uibModal.open(opts);
addScope.addWidget = function(widget){
var w = {
Expand Down Expand Up @@ -1526,46 +1573,6 @@ angular.module('adf')

}]);

/*
* The MIT License
*
* Copyright (c) 2015, Sebastian Sdorra
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


/* global angular */
angular.module('adf')
.filter('adfOrderByObjectKey', ["$filter", function($filter) {


return function(item, key){
var array = [];
angular.forEach(item, function(value, objectKey){
value[key] = objectKey;
array.push(value);
});
return $filter('orderBy')(array, key);
};
}]);

/*
* The MIT License
*
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-dashboard-framework-tpls.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/angular-dashboard-framework-tpls.min.js.map

Large diffs are not rendered by default.

87 changes: 47 additions & 40 deletions dist/angular-dashboard-framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,46 @@ angular.module('adf')
}
}]);

/*
* The MIT License
*
* Copyright (c) 2015, Sebastian Sdorra
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


/* global angular */
angular.module('adf')
.filter('adfOrderByObjectKey', ["$filter", function($filter) {


return function(item, key){
var array = [];
angular.forEach(item, function(value, objectKey){
value[key] = objectKey;
array.push(value);
});
return $filter('orderBy')(array, key);
};
}]);

/*
* The MIT License
*
Expand Down Expand Up @@ -1000,6 +1040,7 @@ angular.module('adf')
* @param {boolean=} enableConfirmDelete true to ask before remove an widget from the dashboard.
* @param {string=} structure the default structure of the dashboard.
* @param {object=} adfModel model object of the dashboard.
* @param {object=} adfAddWidgetModalOptions options to provide to the add-widget modal
* @param {function=} adfWidgetFilter function to filter widgets on the add dialog.
* @param {boolean=} continuousEditMode enable continuous edit mode, to fire add/change/remove
* events during edit mode not reset it if edit mode is exited.
Expand All @@ -1024,6 +1065,7 @@ angular.module('adf')
continuousEditMode: '=',
maximizable: '@',
adfModel: '=',
adfAddWidgetModalOptions: '=',
adfWidgetFilter: '=',
categories: '@'
},
Expand Down Expand Up @@ -1168,6 +1210,7 @@ angular.module('adf')
if (model.structure !== name){
model.structure = name;
}
$rootScope.$broadcast('adfDashboardStructureChange');
};
editDashboardScope.closeDialog = function(){
// copy the new title back to the model
Expand Down Expand Up @@ -1215,6 +1258,10 @@ angular.module('adf')
backdrop: 'static'
};

if (angular.isDefined($scope.adfAddWidgetModalOptions)) {
opts = angular.merge(opts, $scope.adfAddWidgetModalOptions);
}

var instance = $uibModal.open(opts);
addScope.addWidget = function(widget){
var w = {
Expand Down Expand Up @@ -1514,46 +1561,6 @@ angular.module('adf')

}]);

/*
* The MIT License
*
* Copyright (c) 2015, Sebastian Sdorra
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


/* global angular */
angular.module('adf')
.filter('adfOrderByObjectKey', ["$filter", function($filter) {


return function(item, key){
var array = [];
angular.forEach(item, function(value, objectKey){
value[key] = objectKey;
array.push(value);
});
return $filter('orderBy')(array, key);
};
}]);

/*
* The MIT License
*
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-dashboard-framework.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/angular-dashboard-framework.min.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/scripts/directives/adf-dashboard.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* @param {boolean=} enableConfirmDelete true to ask before remove an widget from the dashboard.
* @param {string=} structure the default structure of the dashboard.
* @param {object=} adfModel model object of the dashboard.
* @param {object=} adfAddWidgetModalOptions options to provide to the add-widget modal
* @param {function=} adfWidgetFilter function to filter widgets on the add dialog.
* @param {boolean=} continuousEditMode enable continuous edit mode, to fire add/change/remove
* events during edit mode not reset it if edit mode is exited.
Expand All @@ -64,6 +65,7 @@ angular.module('adf')
continuousEditMode: '=',
maximizable: '@',
adfModel: '=',
adfAddWidgetModalOptions: '=',
adfWidgetFilter: '=',
categories: '@'
},
Expand Down Expand Up @@ -208,6 +210,7 @@ angular.module('adf')
if (model.structure !== name){
model.structure = name;
}
$rootScope.$broadcast('adfDashboardStructureChange');
};
editDashboardScope.closeDialog = function(){
// copy the new title back to the model
Expand Down Expand Up @@ -255,6 +258,10 @@ angular.module('adf')
backdrop: 'static'
};

if (angular.isDefined($scope.adfAddWidgetModalOptions)) {
opts = angular.merge(opts, $scope.adfAddWidgetModalOptions);
}

var instance = $uibModal.open(opts);
addScope.addWidget = function(widget){
var w = {
Expand Down
5 changes: 4 additions & 1 deletion src/templates/dashboard-title.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<h1>
{{model.title}}
<a ng-if="model.titleLink" ng-href="{{model.titleLink}}" target="_blank">
<small title="Open dashboard in separate tab"><i class="glyphicon glyphicon-new-window"></i></small>
</a>
<span style="font-size: 16px" class="pull-right">
<a href="" ng-if="editMode" title="{{ translate('ADF_DASHBOARD_TITLE_TOOLTIP_ADD') }}" ng-click="addWidgetDialog()">
<i class="glyphicon glyphicon-plus-sign"></i>
Expand All @@ -8,7 +11,7 @@ <h1>
<i class="glyphicon glyphicon-cog"></i>
</a>
<a href="" ng-if="options.editable" title="{{editMode ? translate('ADF_DASHBOARD_TITLE_TOOLTIP_SAVE') : translate('ADF_DASHBOARD_TITLE_TOOLTIP_EDIT_MODE') }}" ng-click="toggleEditMode()">
<i class="glyphicon" x-ng-class="{'glyphicon-edit' : !editMode, 'glyphicon-save' : editMode}"></i>
<i class="glyphicon" x-ng-class="{'glyphicon-edit' : !editMode, 'glyphicon-save' : editMode}">{{!editMode ? 'Edit' : 'Save' }}</i>
</a>
<a href="" ng-if="editMode" title="{{ translate('ADF_DASHBOARD_TITLE_TOOLTIP_UNDO') }}" ng-click="cancelEditMode()">
<i class="glyphicon glyphicon-repeat adf-flip"></i>
Expand Down