aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js')
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js43
1 files changed, 30 insertions, 13 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js b/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js
index e57b43ec4..d36b3823f 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js
@@ -20,7 +20,7 @@
"use strict";
-var parameterBlockDirective = function($log, PARAMETER, UtilityService) {
+var parameterBlockDirective = function($log, PARAMETER, UtilityService, $compile) {
/*
* If "IS_SINGLE_OPTION_AUTO_SELECTED" is set to "true" ...
*
@@ -221,6 +221,9 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService) {
+ additionalStyle + "'>" + getOptionListHtml(parameter)
+ "</select>";
break;
+ case PARAMETER.MULTI_SELECT:
+ return '<multiselect id="' + parameter.id + '"' + attributeString + ' ng-model="multiselectModel.' + parameter.id + '" options="getOptionsList(\'' + parameter.id + '\')" display-prop="name" id-prop="id"></multiselect>';
+ break;
case PARAMETER.STRING:
default:
var value = "";
@@ -255,9 +258,7 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService) {
}
if (UtilityService.hasContents(parameter.prompt)) {
- if (!(IS_SINGLE_OPTION_AUTO_SELECTED && parameter.optionList.length === 1) || !(parameter.isSingleOptionAutoSelected && parameter.optionList.length === 1)) {
html += "<option value=''>" + parameter.prompt + "</option>";
- }
}
for (var i = 0; i < parameter.optionList.length; i++) {
@@ -298,7 +299,7 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService) {
var getParameter = function(element, expectedId) {
var id = $(element).attr("parameter-id");
- if (expectedId !== undefined && expectedId !== id) {
+ if (!id || (expectedId !== undefined && expectedId !== id)) {
return undefined;
}
var parameter = {
@@ -327,14 +328,20 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService) {
};
var getRequiredField = function(element) {
- if ($(element).prop("type") === "text") {
- $(element).val($(element).val().trim());
+ if($(element).is("multiselect")) {
+ if(!$(element).find(".active").text().trim()) {
+ return '"' + $(element).attr("parameter-name") + '"';
+ }
}
- if ($(element).val() === "" || $(element).val() === null) {
- return '"' + $(element).attr("parameter-name") + '"';
- } else {
- return "";
+ else {
+ if ($(element).prop("type") === "text") {
+ $(element).val($(element).val().trim());
+ }
+ if ($(element).val() === "" || $(element).val() === null) {
+ return '"' + $(element).attr("parameter-name") + '"';
+ }
}
+ return "";
};
var callback = function(element, scope) {
@@ -354,13 +361,20 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService) {
link : function(scope, element, attrs) {
var control = scope.control || {};
+ scope.multiselectModel = {};
+ scope.getOptionsList = function (parameterId) {
+ return _.find(scope.parameterList, {'id': parameterId})["optionList"];
+ };
control.setList = function(parameterList) {
+ scope.parameterList = parameterList;
+ scope.multiselectModel = {};
var html = "";
for (var i = 0; i < parameterList.length; i++) {
html += getParameterHtml(parameterList[i], attrs.editable);
}
- element.html(html);
+ element.replaceWith($compile(element.html(html))(scope));
+
element.find("input, select").bind("change", function() {
callback(this, scope);
});
@@ -390,13 +404,16 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService) {
parameterList.push(parameter);
}
});
+ angular.forEach(scope.multiselectModel, function(value, key) {
+ parameterList.push({id: key, value: value});
+ });
return parameterList;
}
control.getRequiredFields = function() {
var requiredFields = "";
var count = 0;
- element.find("input, select").each(function() {
+ element.find("input, select, multiselect").each(function() {
if ($(this).attr("is-required") === "true") {
var requiredField = getRequiredField(this);
if (requiredField !== "") {
@@ -418,7 +435,7 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService) {
}
}
-appDS2.directive('parameterBlock', [ "$log", "PARAMETER", "UtilityService",
+appDS2.directive('parameterBlock', [ "$log", "PARAMETER", "UtilityService", "$compile",
parameterBlockDirective ]);