Skip to content

Commit 3dfb641

Browse files
committed
Add some minor changes. Add a new property to override the Widget add
template path to be make it possible to adjust the list of widget's and easy translate them
1 parent e2bf2b0 commit 3dfb641

10 files changed

+72
-15
lines changed

dist/angular-dashboard-framework-tpls.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ angular.module('adf')
691691
$scope.createCategories = createCategories;
692692
}
693693

694-
var adfAddTemplatePath = adfTemplatePath + 'widget-add.html';
694+
var adfAddTemplatePath = dashboard.customWidgetAddTemplatePath ? dashboard.customWidgetAddTemplatePath : adfTemplatePath + 'widget-add.html';
695695
if(model.addTemplateUrl) {
696696
adfAddTemplatePath = model.addTemplateUrl;
697697
}
@@ -919,6 +919,7 @@ angular.module('adf.provider', ['adf.locale'])
919919
</div>\n\
920920
</div>';
921921
var customWidgetTemplatePath = null;
922+
var customWidgetAddTemplatePath = null;
922923

923924
// default apply function of widget.edit.apply
924925
var defaultApplyFunction = function(){
@@ -1117,6 +1118,23 @@ angular.module('adf.provider', ['adf.locale'])
11171118
return this;
11181119
};
11191120

1121+
/**
1122+
* @ngdoc method
1123+
* @name adf.dashboardProvider#customWidgetAddTemplatePath
1124+
* @propertyOf adf.dashboardProvider
1125+
* @description
1126+
*
1127+
* Changes the container template for the widgets
1128+
*
1129+
* @param {string} path to the custom widget template
1130+
*
1131+
* @returns {Object} self
1132+
*/
1133+
this.customWidgetAddTemplatePath = function(templatePath) {
1134+
customWidgetAddTemplatePath = templatePath;
1135+
return this;
1136+
};
1137+
11201138
/**
11211139
* @ngdoc method
11221140
* @name adf.dashboardProvider#setLocale
@@ -1193,6 +1211,7 @@ angular.module('adf.provider', ['adf.locale'])
11931211
messageTemplate: messageTemplate,
11941212
loadingTemplate: loadingTemplate,
11951213
customWidgetTemplatePath: customWidgetTemplatePath,
1214+
customWidgetAddTemplatePath: customWidgetAddTemplatePath,
11961215
setLocale: this.setLocale,
11971216
locales: getLocales,
11981217
activeLocale: getActiveLocale,
@@ -1806,8 +1825,8 @@ angular.module('adf')
18061825
options: '=',
18071826
widgetState: '='
18081827
},
1809-
controller: ["$scope", function($scope) {
1810-
1828+
controller: ["$scope", "$element", function($scope, $element) {
1829+
var widgetEm = $element.find('.widget');
18111830
$scope.$on('adfDashboardCollapseExpand', function(event, args) {
18121831
$scope.widgetState.isCollapsed = args.collapseExpandStatus;
18131832
});
@@ -1867,7 +1886,7 @@ $templateCache.put("../src/templates/dashboard.html","<div class=dashboard-conta
18671886
$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> ");
18681887
$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 | adfOrderByObjectKey: \'key\'\"> <a href ng-click=addWidget(key) ng-bind-html=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) ng-bind-html=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> ");
18691888
$templateCache.put("../src/templates/widget-delete.html","<div class=modal-header> <h4 class=modal-title><span ng-bind=\"translate(\'ADF_COMMON_DELETE\')\">Delete</span> <span ng-bind-html=widget.title></span></h4> </div> <div class=modal-body> <form role=form> <div class=form-group> <label for=widgetTitle ng-bind=\"translate(\'ADF_WIDGET_DELETE_CONFIRM_MESSAGE\')\">Are you sure you want to delete this widget ?</label> </div> </form> </div> <div class=modal-footer> <button type=button class=\"btn btn-default\" ng-click=closeDialog() ng-bind=\"translate(\'ADF_COMMON_CLOSE\')\">Close</button> <button type=button class=\"btn btn-primary\" ng-click=deleteDialog() ng-bind=\"translate(\'ADF_COMMON_DELETE\')\">Delete</button> </div> ");
1870-
$templateCache.put("../src/templates/widget-edit.html","<form name=widgetEditForm novalidate role=form ng-submit=saveDialog()> <div class=modal-header> <button type=button class=close ng-click=closeDialog() aria-hidden=true>&times;</button> <h4 class=modal-title>{{widget.title}}</h4> </div> <div class=modal-body> <div class=\"alert alert-danger\" role=alert ng-show=validationError> <strong>Apply error:</strong> {{validationError}} </div> <div class=form-group> <label for=widgetTitle ng-bind=\"translate(\'ADF_COMMON_TITLE\')\">Title</label> <input type=text class=form-control id=widgetTitle ng-model=definition.title placeholder=\"Enter title\" required> </div> <div ng-if=widget.edit> <adf-widget-content model=definition content=widget.edit> </adf-widget-content></div> </div> <div class=modal-footer> <button type=button class=\"btn btn-default\" ng-click=closeDialog() ng-bind=\"translate(\'ADF_COMMON_CANCEL\')\">Cancel</button> <input type=submit class=\"btn btn-primary\" ng-disabled=widgetEditForm.$invalid ng-value=\"translate(\'ADF_COMMON_APPLY\')\"> </div> </form> ");
1889+
$templateCache.put("../src/templates/widget-edit.html","<form name=widgetEditForm novalidate role=form ng-submit=saveDialog()> <div class=modal-header> <button type=button class=close ng-click=closeDialog() aria-hidden=true>&times;</button> <h4 class=modal-title>{{widget.title}}</h4> </div> <div class=modal-body> <div class=\"alert alert-danger\" role=alert ng-show=validationError> <strong>Apply error:</strong> {{validationError}} </div> <div class=form-group> <label for=widgetTitle ng-bind=\"translate(\'ADF_COMMON_TITLE\')\">Title</label> <input type=text class=form-control id=widgetTitle ng-model=definition.title placeholder=\"Enter title\"> </div> <div ng-if=widget.edit> <adf-widget-content model=definition content=widget.edit> </adf-widget-content></div> </div> <div class=modal-footer> <button type=button class=\"btn btn-default\" ng-click=closeDialog() ng-bind=\"translate(\'ADF_COMMON_CANCEL\')\">Cancel</button> <input type=submit class=\"btn btn-primary\" ng-disabled=widgetEditForm.$invalid ng-value=\"translate(\'ADF_COMMON_APPLY\')\"> </div> </form> ");
18711890
$templateCache.put("../src/templates/widget-fullscreen.html","<div class=modal-header> <div class=\"pull-right widget-icons\"> <a href title=\"{{ translate(\'ADF_WIDGET_TOOLTIP_REFRESH\') }}\" ng-if=widget.reload ng-click=reload()> <i class=\"glyphicon glyphicon-refresh\"></i> </a> <a href title=close ng-click=closeDialog()> <i class=\"glyphicon glyphicon-remove\"></i> </a> </div> <h4 class=modal-title>{{definition.title}}</h4> </div> <div class=modal-body> <adf-widget-content model=definition content=widget> </adf-widget-content></div> <div class=modal-footer> <button type=button class=\"btn btn-primary\" ng-click=closeDialog() ng-bind=\"translate(\'ADF_COMMON_CLOSE\')\">Close</button> </div> ");
18721891
$templateCache.put("../src/templates/widget-title.html","<h3 class=panel-title> {{definition.title}} <span class=pull-right> <a href title=\"{{ translate(\'ADF_WIDGET_TOOLTIP_REFRESH\') }}\" ng-if=widget.reload ng-click=reload()> <i class=\"glyphicon glyphicon-refresh\"></i> </a> <a href title=flytta class=adf-move ng-if=editMode> <i class=\"glyphicon glyphicon-move\"></i> </a> <a href title=\"{{ translate(\'ADF_WIDGET_TOOLTIP_COLLAPSE\') }}\" ng-show=\"options.collapsible && !widgetState.isCollapsed\" ng-click=\"widgetState.isCollapsed = !widgetState.isCollapsed\"> <i class=\"glyphicon glyphicon-minus\"></i> </a> <a href title=\"{{ translate(\'ADF_WIDGET_TOOLTIP_EXPAND\') }}\" ng-show=\"options.collapsible && widgetState.isCollapsed\" ng-click=\"widgetState.isCollapsed = !widgetState.isCollapsed\"> <i class=\"glyphicon glyphicon-plus\"></i> </a> <a href title=\"{{ translate(\'ADF_WIDGET_TOOLTIP_EDIT\') }}\" ng-click=edit() ng-if=editMode> <i class=\"glyphicon glyphicon-cog\"></i> </a> <a href title=\"{{ translate(\'ADF_WIDGET_TOOLTIP_FULLSCREEN\') }}\" ng-click=openFullScreen() ng-show=options.maximizable> <i class=\"glyphicon glyphicon-fullscreen\"></i> </a> <a href title=\"{{ translate(\'ADF_WIDGET_TOOLTIP_REMOVE\') }}\" ng-click=remove() ng-if=editMode> <i class=\"glyphicon glyphicon-remove\"></i> </a> </span> </h3> ");
18731892
$templateCache.put("../src/templates/widget.html","<div adf-id={{definition.wid}} adf-widget-type={{definition.type}} ng-class=\"widgetClasses(widget, definition)\" class=widget> <div class=\"panel-heading clearfix\" ng-if=\"!widget.frameless || editMode\"> <div ng-include src=definition.titleTemplateUrl></div> </div> <div ng-class=\"{\'panel-body\':!widget.frameless || editMode}\" uib-collapse=widgetState.isCollapsed> <adf-widget-content model=definition content=widget> </adf-widget-content></div> </div> ");}]);

dist/angular-dashboard-framework-tpls.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-dashboard-framework-tpls.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-dashboard-framework.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ angular.module('adf')
691691
$scope.createCategories = createCategories;
692692
}
693693

694-
var adfAddTemplatePath = adfTemplatePath + 'widget-add.html';
694+
var adfAddTemplatePath = dashboard.customWidgetAddTemplatePath ? dashboard.customWidgetAddTemplatePath : adfTemplatePath + 'widget-add.html';
695695
if(model.addTemplateUrl) {
696696
adfAddTemplatePath = model.addTemplateUrl;
697697
}
@@ -919,6 +919,7 @@ angular.module('adf.provider', ['adf.locale'])
919919
</div>\n\
920920
</div>';
921921
var customWidgetTemplatePath = null;
922+
var customWidgetAddTemplatePath = null;
922923

923924
// default apply function of widget.edit.apply
924925
var defaultApplyFunction = function(){
@@ -1117,6 +1118,23 @@ angular.module('adf.provider', ['adf.locale'])
11171118
return this;
11181119
};
11191120

1121+
/**
1122+
* @ngdoc method
1123+
* @name adf.dashboardProvider#customWidgetAddTemplatePath
1124+
* @propertyOf adf.dashboardProvider
1125+
* @description
1126+
*
1127+
* Changes the container template for the widgets
1128+
*
1129+
* @param {string} path to the custom widget template
1130+
*
1131+
* @returns {Object} self
1132+
*/
1133+
this.customWidgetAddTemplatePath = function(templatePath) {
1134+
customWidgetAddTemplatePath = templatePath;
1135+
return this;
1136+
};
1137+
11201138
/**
11211139
* @ngdoc method
11221140
* @name adf.dashboardProvider#setLocale
@@ -1193,6 +1211,7 @@ angular.module('adf.provider', ['adf.locale'])
11931211
messageTemplate: messageTemplate,
11941212
loadingTemplate: loadingTemplate,
11951213
customWidgetTemplatePath: customWidgetTemplatePath,
1214+
customWidgetAddTemplatePath: customWidgetAddTemplatePath,
11961215
setLocale: this.setLocale,
11971216
locales: getLocales,
11981217
activeLocale: getActiveLocale,
@@ -1806,8 +1825,8 @@ angular.module('adf')
18061825
options: '=',
18071826
widgetState: '='
18081827
},
1809-
controller: ["$scope", function($scope) {
1810-
1828+
controller: ["$scope", "$element", function($scope, $element) {
1829+
var widgetEm = $element.find('.widget');
18111830
$scope.$on('adfDashboardCollapseExpand', function(event, args) {
18121831
$scope.widgetState.isCollapsed = args.collapseExpandStatus;
18131832
});

dist/angular-dashboard-framework.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-dashboard-framework.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/scripts/dashboard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ angular.module('adf')
437437
$scope.createCategories = createCategories;
438438
}
439439

440-
var adfAddTemplatePath = adfTemplatePath + 'widget-add.html';
440+
var adfAddTemplatePath = dashboard.customWidgetAddTemplatePath ? dashboard.customWidgetAddTemplatePath : adfTemplatePath + 'widget-add.html';
441441
if(model.addTemplateUrl) {
442442
adfAddTemplatePath = model.addTemplateUrl;
443443
}

src/scripts/provider.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ angular.module('adf.provider', ['adf.locale'])
4545
</div>\n\
4646
</div>';
4747
var customWidgetTemplatePath = null;
48+
var customWidgetAddTemplatePath = null;
4849

4950
// default apply function of widget.edit.apply
5051
var defaultApplyFunction = function(){
@@ -243,6 +244,23 @@ angular.module('adf.provider', ['adf.locale'])
243244
return this;
244245
};
245246

247+
/**
248+
* @ngdoc method
249+
* @name adf.dashboardProvider#customWidgetAddTemplatePath
250+
* @propertyOf adf.dashboardProvider
251+
* @description
252+
*
253+
* Changes the container template for the widgets
254+
*
255+
* @param {string} path to the custom widget template
256+
*
257+
* @returns {Object} self
258+
*/
259+
this.customWidgetAddTemplatePath = function(templatePath) {
260+
customWidgetAddTemplatePath = templatePath;
261+
return this;
262+
};
263+
246264
/**
247265
* @ngdoc method
248266
* @name adf.dashboardProvider#setLocale
@@ -319,6 +337,7 @@ angular.module('adf.provider', ['adf.locale'])
319337
messageTemplate: messageTemplate,
320338
loadingTemplate: loadingTemplate,
321339
customWidgetTemplatePath: customWidgetTemplatePath,
340+
customWidgetAddTemplatePath: customWidgetAddTemplatePath,
322341
setLocale: this.setLocale,
323342
locales: getLocales,
324343
activeLocale: getActiveLocale,

src/scripts/widget.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ angular.module('adf')
253253
options: '=',
254254
widgetState: '='
255255
},
256-
controller: function($scope) {
257-
256+
controller: function($scope, $element) {
257+
var widgetEm = $element.find('.widget');
258258
$scope.$on('adfDashboardCollapseExpand', function(event, args) {
259259
$scope.widgetState.isCollapsed = args.collapseExpandStatus;
260260
});

src/templates/widget-edit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h4 class="modal-title">{{widget.title}}</h4>
99
</div>
1010
<div class="form-group">
1111
<label for="widgetTitle" ng-bind="translate('ADF_COMMON_TITLE')">Title</label>
12-
<input type="text" class="form-control" id="widgetTitle" ng-model="definition.title" placeholder="Enter title" required="">
12+
<input type="text" class="form-control" id="widgetTitle" ng-model="definition.title" placeholder="Enter title">
1313
</div>
1414
<div ng-if="widget.edit">
1515
<adf-widget-content model="definition" content="widget.edit" />

0 commit comments

Comments
 (0)