mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
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:
@@ -1058,7 +1058,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
|||||||
id: 'all',
|
id: 'all',
|
||||||
text: 'All'
|
text: 'All'
|
||||||
}];
|
}];
|
||||||
// $('#source_source_regions').select2('data', master.source_regions);
|
|
||||||
}
|
}
|
||||||
if (data.group_by && data.source === 'ec2') {
|
if (data.group_by && data.source === 'ec2') {
|
||||||
set = sources_scope.ec2_group_by;
|
set = sources_scope.ec2_group_by;
|
||||||
|
|||||||
@@ -664,6 +664,24 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
|||||||
* @name shared.function:Utilities#CreateSelect2
|
* @name shared.function:Utilities#CreateSelect2
|
||||||
* @methodOf shared.function:Utilities
|
* @methodOf shared.function:Utilities
|
||||||
* @description Make a regular select drop down a select2 dropdown
|
* @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', [
|
.factory('CreateSelect2', [
|
||||||
function () {
|
function () {
|
||||||
|
|||||||
@@ -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
|
// Enable jqueryui spinner widget on a numeric input field
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -787,7 +787,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
field.awRequiredWhen.variable + "\" " : "";
|
field.awRequiredWhen.variable + "\" " : "";
|
||||||
html += (field.awValidUrl) ? "aw-valid-url " : "";
|
html += (field.awValidUrl) ? "aw-valid-url " : "";
|
||||||
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled=\"" + field.associated + "_ask\" " : "";
|
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled=\"" + field.associated + "_ask\" " : "";
|
||||||
html += (field.awMultiselect) ? "aw-multiselect=\"" + field.awMultiselect + "\" " : "";
|
|
||||||
html += ">\n";
|
html += ">\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,7 +910,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
field.awRequiredWhen.variable + "' " : "";
|
field.awRequiredWhen.variable + "' " : "";
|
||||||
html += (field.awValidUrl) ? "aw-valid-url " : "";
|
html += (field.awValidUrl) ? "aw-valid-url " : "";
|
||||||
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled='" + field.associated + "_ask' " : "";
|
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled='" + field.associated + "_ask' " : "";
|
||||||
html += (field.awMultiselect) ? "aw-multiselect='" + field.awMultiselect + "' " : "";
|
|
||||||
html += ">\n";
|
html += ">\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1042,7 +1040,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
html += (options.mode === 'edit' && field.editRequired) ? "required " : "";
|
html += (options.mode === 'edit' && field.editRequired) ? "required " : "";
|
||||||
html += (options.mode === 'add' && field.addRequired) ? "required " : "";
|
html += (options.mode === 'add' && field.addRequired) ? "required " : "";
|
||||||
html += (field.multiSelect) ? "multiple " : "";
|
html += (field.multiSelect) ? "multiple " : "";
|
||||||
html += (field.awMultiselect) ? "aw-multiselect=\"" + field.awMultiselect + "\" " : "";
|
|
||||||
html += (field.readonly) ? "disabled " : "";
|
html += (field.readonly) ? "disabled " : "";
|
||||||
html += (field.awRequiredWhen) ? "data-awrequired-init=\"" + field.awRequiredWhen.init + "\" aw-required-when=\"" +
|
html += (field.awRequiredWhen) ? "data-awrequired-init=\"" + field.awRequiredWhen.init + "\" aw-required-when=\"" +
|
||||||
field.awRequiredWhen.variable + "\" " : "";
|
field.awRequiredWhen.variable + "\" " : "";
|
||||||
|
|||||||
Reference in New Issue
Block a user