Skip to content

Commit 12fcfbe

Browse files
committed
chore(build)
1 parent 1992eea commit 12fcfbe

File tree

2 files changed

+64
-69
lines changed

2 files changed

+64
-69
lines changed

dist/forms-angular.js

Lines changed: 61 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! forms-angular 2015-02-05 */
1+
/*! forms-angular 2015-02-10 */
22
'use strict';
33

44
var formsAngular = angular.module('formsAngular', [
@@ -43,17 +43,17 @@ formsAngular.controller('BaseCtrl', [
4343
}
4444
}
4545
])
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+
}]);
5757

5858
'use strict';
5959

@@ -279,35 +279,6 @@ formsAngular
279279
var subkeys = [];
280280
var tabsSetup = false;
281281

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-
311282
var generateInput = function (fieldInfo, modelString, isRequired, idString, options) {
312283
var nameString;
313284
if (!modelString) {
@@ -529,30 +500,7 @@ formsAngular
529500
};
530501

531502
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);
556504
var template = fieldChrome.template;
557505

558506
if (info.schema) {
@@ -664,6 +612,10 @@ formsAngular
664612
// var processInstructions = function (instructionsArray, topLevel, groupId) {
665613
// removing groupId as it was only used when called by containerType container, which is removed for now
666614
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+
}
667619
var result = '';
668620
if (instructionsArray) {
669621
for (var anInstruction = 0; anInstruction < instructionsArray.length; anInstruction++) {
@@ -2148,14 +2100,57 @@ formsAngular.factory('formMarkupHelper', [
21482100
function (cssFrameworkService, inputSizeHelper, addAllService) {
21492101
var exports = {};
21502102

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+
21512133
exports.isHorizontalStyle = function (formStyle) {
21522134
return (!formStyle || formStyle === 'undefined' || ['vertical', 'inline'].indexOf(formStyle) === -1);
21532135
};
21542136

2155-
exports.fieldChrome = function (scope, info, options, insert) {
2137+
exports.fieldChrome = function (scope, info, options) {
21562138
var classes = '';
21572139
var template = '';
21582140
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+
21592154

21602155
if (cssFrameworkService.framework() === 'bs3') {
21612156
classes = 'form-group';

0 commit comments

Comments
 (0)