Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Juan Ferrer 2019-10-01 16:21:20 +02:00
commit 34e141e159
4 changed files with 1 additions and 199 deletions

View File

@ -2,7 +2,6 @@ import './module-loader';
import './crud'; import './crud';
import './acl-service'; import './acl-service';
import './template'; import './template';
import './interpolate';
import './copy'; import './copy';
import './equals'; import './equals';
import './modified'; import './modified';

View File

@ -1,189 +0,0 @@
import ngModule from '../module';
import {ng} from '../vendor';
function stringify(value) {
if (value === null) { // null || undefined
return '';
}
switch (typeof value) {
case 'string':
break;
case 'number':
value = String(value);
break;
default:
value = angular.toJson(value);
}
return value;
}
var $interpolateMinErr = ng.$interpolateMinErr = ng.$$minErr('$interpolate');
$interpolateMinErr.throwNoconcat = function(text) {
throw $interpolateMinErr('noconcat',
'Error while interpolating: {0}\nStrict Contextual Escaping disallows ' +
'interpolations that concatenate multiple expressions when a trusted value is ' +
'required. See http://docs.angularjs.org/api/ng.$sce', text);
};
$interpolateMinErr.interr = function(text, err) {
return $interpolateMinErr('interr', 'Can\'t interpolate: {0}\n{1}', text, err.toString());
};
function $get($parse, $exceptionHandler, $sce) {
let startSymbolLength = this._startSymbol.length;
let endSymbolLength = this._endSymbol.length;
let escapedStartRegexp = new RegExp(this._startSymbol.replace(/./g, escape), 'g');
let escapedEndRegexp = new RegExp(this._endSymbol.replace(/./g, escape), 'g');
let self = this;
function escape(ch) {
return '\\\\\\' + ch;
}
function unescapeText(text) {
return text.replace(escapedStartRegexp, self._startSymbol)
.replace(escapedEndRegexp, self._endSymbol);
}
// TODO: this is the same as the constantWatchDelegate in parse.js
function constantWatchDelegate(scope, listener, objectEquality, constantInterp) {
var unwatch = scope.$watch(function constantInterpolateWatch(scope) {
unwatch();
return constantInterp(scope);
}, listener, objectEquality);
return unwatch;
}
function $interpolate(text, mustHaveExpression, trustedContext, allOrNothing) {
// Provide a quick exit and simplified result function for text with no interpolation
if (!text.length || text.indexOf(self._startSymbol) === -1) {
var constantInterp;
if (!mustHaveExpression) {
var unescapedText = unescapeText(text);
constantInterp = valueFn(unescapedText);
constantInterp.exp = text;
constantInterp.expressions = [];
constantInterp.$$watchDelegate = constantWatchDelegate;
}
return constantInterp;
}
allOrNothing = Boolean(allOrNothing);
let startIndex;
let endIndex;
let index = 0;
let expressions = [];
let parseFns = [];
let textLength = text.length;
let exp;
let concat = [];
let expressionPositions = [];
while (index < textLength) {
if (((startIndex = text.indexOf(self._startSymbol, index)) !== -1) &&
((endIndex = text.indexOf(self._endSymbol, startIndex + startSymbolLength)) !== -1)) {
if (index !== startIndex)
concat.push(unescapeText(text.substring(index, startIndex)));
exp = text.substring(startIndex + startSymbolLength, endIndex);
expressions.push(exp);
parseFns.push($parse(exp, parseStringifyInterceptor));
index = endIndex + endSymbolLength;
expressionPositions.push(concat.length);
concat.push('');
} else {
// we did not find an interpolation, so we have to add the remainder to the separators array
if (index !== textLength)
concat.push(unescapeText(text.substring(index)));
break;
}
}
if (trustedContext && concat.length > 1) {
$interpolateMinErr.throwNoconcat(text);
}
var getValue = function(value) {
return trustedContext ?
$sce.getTrusted(trustedContext, value) :
$sce.valueOf(value);
};
if (!mustHaveExpression || expressions.length) {
var compute = function(values) {
for (var i = 0, ii = expressions.length; i < ii; i++) {
if (allOrNothing && isUndefined(values[i])) return;
concat[expressionPositions[i]] = values[i];
}
return concat.join('');
};
return angular.extend(function interpolationFn(context) {
var i = 0;
var ii = expressions.length;
var values = new Array(ii);
try {
for (; i < ii; i++) {
values[i] = parseFns[i](context);
}
return compute(values);
} catch (err) {
$exceptionHandler($interpolateMinErr.interr(text, err));
}
}, {
// all of these properties are undocumented for now
exp: text, // just for compatibility with regular watchers created via $watch
expressions: expressions
});
}
function parseStringifyInterceptor(value) {
try {
value = getValue(value);
return allOrNothing && !isDefined(value) ? value : stringify(value);
} catch (err) {
$exceptionHandler($interpolateMinErr.interr(text, err));
}
}
}
$interpolate.startSymbol = function() {
return startSymbol;
};
$interpolate.endSymbol = function() {
return endSymbol;
};
return $interpolate;
}
$get.$inject = ['$parse', '$exceptionHandler', '$sce'];
export class Interpolate {
constructor() {
this._startSymbol = '*[';
this._endSymbol = ']*';
}
set startSymbol(value) {
if (value) {
this._startSymbol = value;
return this;
}
return this._startSymbol;
}
set endSymbol(value) {
if (value) {
this._endSymbol = value;
return this;
}
return this._endSymbol;
}
}
Interpolate.prototype.$get = $get;
var interpolate = new Interpolate();
ngModule.provider('vnInterpolate', () => interpolate);

View File

@ -1,13 +1,6 @@
import ngModule from '../module'; import ngModule from '../module';
export default class Template { export default class Template {
constructor(vnInterpolate) {
this.vnInterpolate = vnInterpolate;
}
get(template, $attrs, defaults) {
let scope = Object.assign({}, defaults, $attrs);
return template && this.vnInterpolate(template)(scope);
}
getNormalized(template, $attrs, defaults) { getNormalized(template, $attrs, defaults) {
this.normalizeInputAttrs($attrs); this.normalizeInputAttrs($attrs);
return this.get(template, $attrs, defaults); return this.get(template, $attrs, defaults);
@ -43,6 +36,5 @@ export default class Template {
$attrs.focus = 'vn-focus'; $attrs.focus = 'vn-focus';
} }
} }
Template.$inject = ['vnInterpolate'];
ngModule.service('vnTemplate', Template); ngModule.service('vnTemplate', Template);

View File

@ -168,7 +168,7 @@ module.exports = Self => {
} }
function isAlpha(value) { function isAlpha(value) {
const regexp = new RegExp(/^[ñça-zA-Z0-9\s]*$/); const regexp = new RegExp(/^[ñça-zA-Z0-9\s]*$/i);
return regexp.test(value); return regexp.test(value);
} }