select2 comments and removal of stale awMultiSelect

adding comments for how to implement the select2 on a select field, and removing the directive that no longer creates select2 fields
This commit is contained in:
Jared Tabor
2015-04-20 12:34:14 -04:00
parent d27a190b4e
commit 2bd856da93
4 changed files with 18 additions and 31 deletions

View File

@@ -1058,7 +1058,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
id: 'all',
text: 'All'
}];
// $('#source_source_regions').select2('data', master.source_regions);
}
if (data.group_by && data.source === 'ec2') {
set = sources_scope.ec2_group_by;

View File

@@ -664,6 +664,24 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
* @name shared.function:Utilities#CreateSelect2
* @methodOf shared.function:Utilities
* @description Make a regular select drop down a select2 dropdown
* To make a ``<select>`` field a select2 select 2, create the field in the
* form definition with the multiSelect flag set to true. In the controller
* of the page in question, call the CreateSelect2 factory with the element
* id (be sure to include the appropriate jquery identifier in the parameter)
* or any options that should be pre-selected in the select2 field.
* The array of options should be formatted as
* ```
* [
* {
* id: 'id' ,
* text: 'text'
* },
* {
* id: 'id' ,
* text: 'text'
* }
* ]
* ```
*/
.factory('CreateSelect2', [
function () {

View File

@@ -620,33 +620,6 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
};
}])
.directive('awMultiSelect', [ function() {
return {
require: 'ngModel',
link: function(scope, elm) {
$(elm).multiselect ({
buttonClass: 'btn-default, btn-mini',
buttonWidth: 'auto',
buttonContainer: '<div class="btn-group" />',
maxHeight: false,
buttonText: function(options) {
if (options.length === 0) {
return 'None selected <b class="caret"></b>';
}
if (options.length > 3) {
return options.length + ' selected <b class="caret"></b>';
}
var selected = '';
options.each(function() {
selected += $(this).text() + ', ';
});
return selected.substr(0, selected.length -2) + ' <b class="caret"></b>';
}
});
}
};
}])
//
// Enable jqueryui spinner widget on a numeric input field
//

View File

@@ -787,7 +787,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
field.awRequiredWhen.variable + "\" " : "";
html += (field.awValidUrl) ? "aw-valid-url " : "";
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled=\"" + field.associated + "_ask\" " : "";
html += (field.awMultiselect) ? "aw-multiselect=\"" + field.awMultiselect + "\" " : "";
html += ">\n";
}
@@ -911,7 +910,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
field.awRequiredWhen.variable + "' " : "";
html += (field.awValidUrl) ? "aw-valid-url " : "";
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled='" + field.associated + "_ask' " : "";
html += (field.awMultiselect) ? "aw-multiselect='" + field.awMultiselect + "' " : "";
html += ">\n";
}
@@ -1042,7 +1040,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += (options.mode === 'edit' && field.editRequired) ? "required " : "";
html += (options.mode === 'add' && field.addRequired) ? "required " : "";
html += (field.multiSelect) ? "multiple " : "";
html += (field.awMultiselect) ? "aw-multiselect=\"" + field.awMultiselect + "\" " : "";
html += (field.readonly) ? "disabled " : "";
html += (field.awRequiredWhen) ? "data-awrequired-init=\"" + field.awRequiredWhen.init + "\" aw-required-when=\"" +
field.awRequiredWhen.variable + "\" " : "";