mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-30 07:56:05 +00:00
fix strip url
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
"type": "text"
|
||||
},
|
||||
"website": {
|
||||
"type": "url"
|
||||
"type": "url",
|
||||
"strip": true
|
||||
},
|
||||
"emailAddress": {
|
||||
"type": "email"
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"trim": true
|
||||
},
|
||||
"website": {
|
||||
"type": "url"
|
||||
"type": "url",
|
||||
"strip": true
|
||||
},
|
||||
"emailAddress": {
|
||||
"type": "email",
|
||||
|
||||
@@ -57,7 +57,8 @@
|
||||
"readOnly": true
|
||||
},
|
||||
"website": {
|
||||
"type": "url"
|
||||
"type": "url",
|
||||
"strip": true
|
||||
},
|
||||
"address": {
|
||||
"type": "address",
|
||||
|
||||
@@ -165,7 +165,8 @@
|
||||
"maxFileSize": "Max File Size (Mb)",
|
||||
"isPersonalData": "Is Personal Data",
|
||||
"useIframe": "Use Iframe",
|
||||
"useNumericFormat": "Use Numeric Format"
|
||||
"useNumericFormat": "Use Numeric Format",
|
||||
"strip": "Strip"
|
||||
},
|
||||
"messages": {
|
||||
"upgradeVersion": "EspoCRM will be upgraded to version <strong>{version}</strong>. Please be patient as this may take a while.",
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
"name":"maxLength",
|
||||
"type":"int"
|
||||
},
|
||||
{
|
||||
"name": "strip",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name":"audited",
|
||||
"type":"bool"
|
||||
|
||||
@@ -47,6 +47,31 @@ Espo.define('views/fields/url', 'views/fields/varchar', function (Dep) {
|
||||
}, Dep.prototype.data.call(this));
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
|
||||
if (this.mode === 'edit') {
|
||||
if (this.params.strip) {
|
||||
this.$element.on('change', function () {
|
||||
var value = this.$element.val() || '';
|
||||
value = this.strip(value);
|
||||
this.$element.val(value);
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
strip: function (value) {
|
||||
value = value.trim();
|
||||
if (value.indexOf('http://') === 0) {
|
||||
value = value.substr(7);
|
||||
} else if (value.indexOf('https://') === 0) {
|
||||
value = value.substr(8);
|
||||
}
|
||||
value = value.replace(/\/+$/, '');
|
||||
return value;
|
||||
},
|
||||
|
||||
getUrl: function () {
|
||||
var url = this.model.get(this.name);
|
||||
if (url && url != '') {
|
||||
@@ -56,8 +81,16 @@ Espo.define('views/fields/url', 'views/fields/varchar', function (Dep) {
|
||||
return url;
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
fetch: function () {
|
||||
var data = Dep.prototype.fetch.call(this);
|
||||
|
||||
if (this.params.strip) {
|
||||
data[this.name] = this.strip(data[this.name]);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user