\n";
- }
-
- if (options.activityStream) {
- // Add a title row
- html += "
\n";
- html += "
\n";
- html += "
{{ streamTitle }} \n";
- html += "\n";
- html += "
\n";
- }
-
- if (options.showSearch=== undefined || options.showSearch === true) {
- html += "
\n";
- if (list.name !== 'groups') {
- if (options.searchSize) {
- html += SearchWidget({
- iterator: list.iterator,
- template: list,
- mini: true,
- size: options.searchSize,
- searchWidgets: list.searchWidgets
- });
- } else if (options.mode === 'summary') {
- html += SearchWidget({
- iterator: list.iterator,
- template: list,
- mini: true,
- size: 'col-lg-6'
- });
- } else if (options.mode === 'lookup' || options.id !== undefined) {
- html += SearchWidget({
- iterator: list.iterator,
- template: list,
- mini: true,
- size: 'col-lg-8'
- });
- } else {
- html += SearchWidget({
- iterator: list.iterator,
- template: list,
- mini: true
- });
- }
- }
-
- if (options.mode !== 'lookup') {
- //actions
- base = $location.path().replace(/^\//, '').split('/')[0];
- html += "
\n";
-
- html += "
\n";
-
- // Add toolbar buttons or 'actions'
- for (action in list.actions) {
- if (list.actions[action].mode === 'all' || list.actions[action].mode === options.mode) {
- if ((list.actions[action].basePaths === undefined) ||
- (list.actions[action].basePaths && list.actions[action].basePaths.indexOf(base) > -1)) {
- html += this.button({
- btn: list.actions[action],
- action: action,
- toolbar: true
- });
- }
- }
- }
-
- //select instructions
- if (options.mode === 'select' && list.selectInstructions) {
- btn = {
- awPopOver: list.selectInstructions,
- dataPlacement: 'left',
- dataContainer: 'body',
- 'class': 'btn-xs btn-help',
- awToolTip: 'Click for help',
- dataTitle: 'Help',
- iconSize: 'fa-lg'
- };
- //html += this.button(btn, 'select');
- html += this.button({
- btn: btn,
- action: 'help',
- toolbar: true
- });
- }
-
- html += "
\n";
- html += "
\n";
- } else {
- //lookup
- html += "
\n";
- }
- html += "
\n";
- }
-
- // Add a title and optionally a close button (used on Inventory->Groups)
- if (options.mode !== 'lookup' && list.showTitle) {
- html += "
";
- html += (options.mode === 'edit' || options.mode === 'summary') ? list.editTitle : list.addTitle;
- html += "
\n";
- }
-
- // table header row
- html += "
\n";
- html += "
\n";
- html += "
\n";
-
- if (options.mode === 'select' && (options.selectButton === undefined || options.selectButton)) {
- html += "
\n";
- html += " Select \n";
- html += "
\n";
- }
-
- if (options.mode !== 'lookup' && (list.well === undefined || list.well === true)) {
- html += "
\n"; //well
- }
-
- if (list.name !== 'groups') {
- if (options.mode === 'lookup' || (options.id && options.id === "form-modal-body")) {
- html += PaginateWidget({
- set: list.name,
- iterator: list.iterator
- });
- } else {
- html += PaginateWidget({
- set: list.name,
- iterator: list.iterator
- });
- }
- }
-
- return html;
+ if (options.id) {
+ element = angular.element(document.getElementById(options.id));
+ } else {
+ element = angular.element(document.getElementById('htmlTemplate'));
}
- };
- }
- ]);
\ No newline at end of file
+
+ this.setOptions(options);
+ this.setList(list);
+ element.html(this.build(options)); // Inject the html
+
+ if (options.prepend) {
+ element.prepend(options.prepend);
+ }
+
+ if (options.append) {
+ element.append(options.append);
+ }
+
+ if (options.scope) {
+ this.scope = options.scope;
+ } else {
+ this.scope = element.scope();
+ }
+
+ $compile(element)(this.scope);
+
+ // Reset the scope to prevent displaying old data from our last visit to this list
+ //this.scope[list.name] = null;
+ this.scope[list.iterator] = [];
+
+ // Remove any lingering tooltip and popover elements
+ $('.tooltip').each(function() {
+ $(this).remove();
+ });
+
+ $('.popover').each(function() {
+ // remove lingering popover
. Seems to be a bug in TB3 RC1
+ $(this).remove();
+ });
+ $(window).unbind('resize');
+
+ try {
+ $('#help-modal').empty().dialog('destroy');
+ } catch (e) {
+ //ignore any errors should the dialog not be initialized
+ }
+
+ /*if (options.mode === 'lookup') {
+ // options should include {hdr:
, action: }
+ this.scope.formModalActionDisabled = false;
+ this.scope.lookupHeader = options.hdr;
+ $('#lookup-modal').modal({
+ backdrop: 'static',
+ keyboard: true
+ });
+ $('#lookup-modal').unbind('hidden.bs.modal');
+ $(document).bind('keydown', function (e) {
+ if (e.keyCode === 27) {
+ $('#lookup-modal').modal('hide');
+ }
+ });
+ }*/
+
+ return this.scope;
+ },
+
+ build: function (options) {
+ //
+ // Generate HTML. Do NOT call this function directly. Called by inject(). Returns an HTML
+ // string to be injected into the current view.
+ //
+ var html = '',
+ list = this.list,
+ base, size, action, btn, fld, cnt, field_action, fAction, itm;
+
+ if (options.activityStream) {
+ // Breadcrumbs for activity stream widget
+ // Make the links clickable using ng-click function so we can first remove the stream widget
+ // before navigation
+ html += "\n";
+ } else if (options.mode !== 'lookup' && (options.breadCrumbs === undefined || options.breadCrumbs)) {
+ //Breadcrumbs
+ html += Breadcrumbs({
+ list: list,
+ mode: options.mode
+ });
+ }
+
+ if (options.mode === 'edit' && list.editInstructions) {
+ html += "\n";
+ html += "× \n";
+ html += "Hint: " + list.editInstructions + "\n";
+ html += "
\n";
+ }
+
+ if (options.instructions) {
+ html += "" + options.instructions + "
\n";
+ }
+ else if (list.instructions) {
+ html += "" + list.instructions + "
\n";
+ }
+
+ if (options.mode !== 'lookup' && (list.well === undefined || list.well)) {
+ html += "\n";
+ }
+
+ if (options.activityStream) {
+ // Add a title row
+ html += "
\n";
+ html += "
\n";
+ html += "
{{ streamTitle }} \n";
+ html += "\n";
+ html += "
\n";
+ }
+
+ if (options.showSearch=== undefined || options.showSearch === true) {
+ html += "
\n";
+ if (list.name !== 'groups') {
+ if (options.searchSize) {
+ html += SearchWidget({
+ iterator: list.iterator,
+ template: list,
+ mini: true,
+ size: options.searchSize,
+ searchWidgets: list.searchWidgets
+ });
+ } else if (options.mode === 'summary') {
+ html += SearchWidget({
+ iterator: list.iterator,
+ template: list,
+ mini: true,
+ size: 'col-lg-6'
+ });
+ } else if (options.mode === 'lookup' || options.id !== undefined) {
+ html += SearchWidget({
+ iterator: list.iterator,
+ template: list,
+ mini: true,
+ size: 'col-lg-8'
+ });
+ } else {
+ html += SearchWidget({
+ iterator: list.iterator,
+ template: list,
+ mini: true
+ });
+ }
+ }
+
+ if (options.mode !== 'lookup') {
+ //actions
+ base = $location.path().replace(/^\//, '').split('/')[0];
+ html += "
\n";
+
+ html += "
\n";
+
+ // Add toolbar buttons or 'actions'
+ for (action in list.actions) {
+ if (list.actions[action].mode === 'all' || list.actions[action].mode === options.mode) {
+ if ((list.actions[action].basePaths === undefined) ||
+ (list.actions[action].basePaths && list.actions[action].basePaths.indexOf(base) > -1)) {
+ html += this.button({
+ btn: list.actions[action],
+ action: action,
+ toolbar: true
+ });
+ }
+ }
+ }
+
+ //select instructions
+ if (options.mode === 'select' && list.selectInstructions) {
+ btn = {
+ awPopOver: list.selectInstructions,
+ dataPlacement: 'left',
+ dataContainer: 'body',
+ 'class': 'btn-xs btn-help',
+ awToolTip: 'Click for help',
+ dataTitle: 'Help',
+ iconSize: 'fa-lg'
+ };
+ //html += this.button(btn, 'select');
+ html += this.button({
+ btn: btn,
+ action: 'help',
+ toolbar: true
+ });
+ }
+
+ html += "
\n";
+ html += "
\n";
+ } else {
+ //lookup
+ html += "
\n";
+ }
+ html += "
\n";
+ }
+
+ // Add a title and optionally a close button (used on Inventory->Groups)
+ if (options.mode !== 'lookup' && list.showTitle) {
+ html += "
";
+ html += (options.mode === 'edit' || options.mode === 'summary') ? list.editTitle : list.addTitle;
+ html += "
\n";
+ }
+
+ // table header row
+ html += "
\n";
+ html += "
\n";
+ html += "
\n";
+
+ if (options.mode === 'select' && (options.selectButton === undefined || options.selectButton)) {
+ html += "
\n";
+ html += " Select \n";
+ html += "
\n";
+ }
+
+ if (options.mode !== 'lookup' && (list.well === undefined || list.well === true)) {
+ html += "
\n"; //well
+ }
+
+ if (list.name !== 'groups') {
+ if (options.mode === 'lookup' || (options.id && options.id === "form-modal-body")) {
+ html += PaginateWidget({
+ set: list.name,
+ iterator: list.iterator
+ });
+ } else {
+ html += PaginateWidget({
+ set: list.name,
+ iterator: list.iterator
+ });
+ }
+ }
+
+ return html;
+ },
+
+ buildHeader: function(options) {
+ var list = this.list,
+ fld, html;
+
+ if (options === undefined) {
+ options = this.options;
+ }
+
+ html = "\n";
+ html += "\n";
+ if (list.index) {
+ html += "# \n";
+ }
+ for (fld in list.fields) {
+ if ((list.fields[fld].searchOnly === undefined || list.fields[fld].searchOnly === false) &&
+ !(options.mode === 'lookup' && list.fields[fld].excludeModal !== undefined && list.fields[fld].excludeModal === true)) {
+ html += "\n";
+ }
+ }
+ if (options.mode === 'select' || options.mode === 'lookup') {
+ html += "Select ";
+ } else if (options.mode === 'edit' && list.fieldActions) {
+ html += "Actions \n";
+ }
+ html += " \n";
+ html += " \n";
+ return html;
+ }
+ };
+ }]);
\ No newline at end of file