|
1 |
| -/*! forms-angular 2015-02-05 */ |
| 1 | +/*! forms-angular 2015-02-10 */ |
2 | 2 | 'use strict';
|
3 | 3 |
|
4 | 4 | var formsAngular = angular.module('formsAngular', [
|
@@ -43,17 +43,17 @@ formsAngular.controller('BaseCtrl', [
|
43 | 43 | }
|
44 | 44 | }
|
45 | 45 | ])
|
46 |
| - .controller('SaveChangesModalCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) { |
47 |
| - $scope.yes = function () { |
48 |
| - $modalInstance.close(true); |
49 |
| - }; |
50 |
| - $scope.no = function () { |
51 |
| - $modalInstance.close(false); |
52 |
| - }; |
53 |
| - $scope.cancel = function () { |
54 |
| - $modalInstance.dismiss('cancel'); |
55 |
| - }; |
56 |
| - }]); |
| 46 | +.controller('SaveChangesModalCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) { |
| 47 | + $scope.yes = function () { |
| 48 | + $modalInstance.close(true); |
| 49 | + }; |
| 50 | + $scope.no = function () { |
| 51 | + $modalInstance.close(false); |
| 52 | + }; |
| 53 | + $scope.cancel = function () { |
| 54 | + $modalInstance.dismiss('cancel'); |
| 55 | + }; |
| 56 | +}]); |
57 | 57 |
|
58 | 58 | 'use strict';
|
59 | 59 |
|
@@ -279,35 +279,6 @@ formsAngular
|
279 | 279 | var subkeys = [];
|
280 | 280 | var tabsSetup = false;
|
281 | 281 |
|
282 |
| - var generateNgShow = function (showWhen, model) { |
283 |
| - |
284 |
| - function evaluateSide(side) { |
285 |
| - var result = side; |
286 |
| - if (typeof side === 'string') { |
287 |
| - if (side.slice(0, 1) === '$') { |
288 |
| - result = (model || 'record') + '.'; |
289 |
| - var parts = side.slice(1).split('.'); |
290 |
| - if (parts.length > 1) { |
291 |
| - var lastBit = parts.pop(); |
292 |
| - result += parts.join('.') + '[$index].' + lastBit; |
293 |
| - } else { |
294 |
| - result += side.slice(1); |
295 |
| - } |
296 |
| - } else { |
297 |
| - result = '\'' + side + '\''; |
298 |
| - } |
299 |
| - } |
300 |
| - return result; |
301 |
| - } |
302 |
| - |
303 |
| - var conditionText = ['eq', 'ne', 'gt', 'gte', 'lt', 'lte'], |
304 |
| - conditionSymbols = ['===', '!==', '>', '>=', '<', '<='], |
305 |
| - conditionPos = conditionText.indexOf(showWhen.comp); |
306 |
| - |
307 |
| - if (conditionPos === -1) { throw new Error('Invalid comparison in showWhen'); } |
308 |
| - return evaluateSide(showWhen.lhs) + conditionSymbols[conditionPos] + evaluateSide(showWhen.rhs); |
309 |
| - }; |
310 |
| - |
311 | 282 | var generateInput = function (fieldInfo, modelString, isRequired, idString, options) {
|
312 | 283 | var nameString;
|
313 | 284 | if (!modelString) {
|
@@ -529,30 +500,7 @@ formsAngular
|
529 | 500 | };
|
530 | 501 |
|
531 | 502 | var handleField = function (info, options) {
|
532 |
| - var includeIndex = false; |
533 |
| - var insert = ''; |
534 |
| - if (options.index) { |
535 |
| - try { |
536 |
| - parseInt(options.index); |
537 |
| - includeIndex = true; |
538 |
| - } catch (err) { |
539 |
| - // Nothing to do |
540 |
| - } |
541 |
| - } |
542 |
| - if (info.showWhen) { |
543 |
| - if (typeof info.showWhen === 'string') { |
544 |
| - insert += 'ng-show="' + info.showWhen + '"'; |
545 |
| - } else { |
546 |
| - insert += 'ng-show="' + generateNgShow(info.showWhen, options.model) + '"'; |
547 |
| - } |
548 |
| - } |
549 |
| - if (includeIndex) { |
550 |
| - insert += ' id="cg_' + info.id.replace('_', '-' + attrs.index + '-') + '"'; |
551 |
| - } else { |
552 |
| - insert += ' id="cg_' + info.id.replace(/\./g, '-') + '"'; |
553 |
| - } |
554 |
| - |
555 |
| - var fieldChrome = formMarkupHelper.fieldChrome(scope, info, options, insert); |
| 503 | + var fieldChrome = formMarkupHelper.fieldChrome(scope, info, options); |
556 | 504 | var template = fieldChrome.template;
|
557 | 505 |
|
558 | 506 | if (info.schema) {
|
@@ -664,6 +612,10 @@ formsAngular
|
664 | 612 | // var processInstructions = function (instructionsArray, topLevel, groupId) {
|
665 | 613 | // removing groupId as it was only used when called by containerType container, which is removed for now
|
666 | 614 | var processInstructions = function (instructionsArray, topLevel, options) {
|
| 615 | + if (options.index) { |
| 616 | + alert('Found where options index is used'); // This is tested for shen generating field chrome, but cannot see how it is ever generated. Redundant? AM removing 9/2/15 |
| 617 | + throw new Error('Found where options index is used'); |
| 618 | + } |
667 | 619 | var result = '';
|
668 | 620 | if (instructionsArray) {
|
669 | 621 | for (var anInstruction = 0; anInstruction < instructionsArray.length; anInstruction++) {
|
@@ -2148,14 +2100,57 @@ formsAngular.factory('formMarkupHelper', [
|
2148 | 2100 | function (cssFrameworkService, inputSizeHelper, addAllService) {
|
2149 | 2101 | var exports = {};
|
2150 | 2102 |
|
| 2103 | + function generateNgShow(showWhen, model) { |
| 2104 | + |
| 2105 | + function evaluateSide(side) { |
| 2106 | + var result = side; |
| 2107 | + if (typeof side === 'string') { |
| 2108 | + if (side.slice(0, 1) === '$') { |
| 2109 | + result = (model || 'record') + '.'; |
| 2110 | + var parts = side.slice(1).split('.'); |
| 2111 | + if (parts.length > 1) { |
| 2112 | + var lastBit = parts.pop(); |
| 2113 | + result += parts.join('.') + '[$index].' + lastBit; |
| 2114 | + } else { |
| 2115 | + result += side.slice(1); |
| 2116 | + } |
| 2117 | + } else { |
| 2118 | + result = '\'' + side + '\''; |
| 2119 | + } |
| 2120 | + } |
| 2121 | + return result; |
| 2122 | + } |
| 2123 | + |
| 2124 | + var conditionText = ['eq', 'ne', 'gt', 'gte', 'lt', 'lte'], |
| 2125 | + conditionSymbols = ['===', '!==', '>', '>=', '<', '<='], |
| 2126 | + conditionPos = conditionText.indexOf(showWhen.comp); |
| 2127 | + |
| 2128 | + if (conditionPos === -1) { throw new Error('Invalid comparison in showWhen'); } |
| 2129 | + return evaluateSide(showWhen.lhs) + conditionSymbols[conditionPos] + evaluateSide(showWhen.rhs); |
| 2130 | + } |
| 2131 | + |
| 2132 | + |
2151 | 2133 | exports.isHorizontalStyle = function (formStyle) {
|
2152 | 2134 | return (!formStyle || formStyle === 'undefined' || ['vertical', 'inline'].indexOf(formStyle) === -1);
|
2153 | 2135 | };
|
2154 | 2136 |
|
2155 |
| - exports.fieldChrome = function (scope, info, options, insert) { |
| 2137 | + exports.fieldChrome = function (scope, info, options) { |
2156 | 2138 | var classes = '';
|
2157 | 2139 | var template = '';
|
2158 | 2140 | var closeTag = '';
|
| 2141 | + var insert = ''; |
| 2142 | + |
| 2143 | + info.showWhen = info.showWhen || info.showwhen; // deal with use within a directive |
| 2144 | + |
| 2145 | + if (info.showWhen) { |
| 2146 | + if (typeof info.showWhen === 'string') { |
| 2147 | + insert += 'ng-show="' + info.showWhen + '"'; |
| 2148 | + } else { |
| 2149 | + insert += 'ng-show="' + generateNgShow(info.showWhen, options.model) + '"'; |
| 2150 | + } |
| 2151 | + } |
| 2152 | + insert += ' id="cg_' + info.id.replace(/\./g, '-') + '"'; |
| 2153 | + |
2159 | 2154 |
|
2160 | 2155 | if (cssFrameworkService.framework() === 'bs3') {
|
2161 | 2156 | classes = 'form-group';
|
|
0 commit comments