Etemplate: Change r/o URLs to use label as link text

This commit is contained in:
nathangray 2021-06-04 10:50:23 -06:00
parent d45ae8f330
commit b7fab5d414
4 changed files with 58 additions and 4 deletions

View File

@ -159,7 +159,7 @@ var et2_customfields_list = /** @class */ (function (_super) {
'id': id,
'statustext': field.help,
'needed': field.needed,
'readonly': this.getArrayMgr("readonlys").isReadOnly(id, null, this.options.readonly),
'readonly': this.getArrayMgr("readonlys").isReadOnly(id, "" + this.options.readonly),
'value': this.options.value[this.options.prefix + field_name]
});
// Can't have a required readonly, it will warn & be removed later, so avoid the warning
@ -547,6 +547,18 @@ var et2_customfields_list = /** @class */ (function (_super) {
}
return false;
};
/**
* Display links in list as CF name
* @param field_name
* @param field
* @param attrs
*/
et2_customfields_list.prototype._setup_url = function (field_name, field, attrs) {
if (this.getType() == 'customfields-list') {
attrs.label = field.label;
}
return true;
};
/**
* Set which fields are visible, by name
*

View File

@ -21,6 +21,7 @@
import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_valueWidget} from "./et2_core_valueWidget";
import {et2_readonlysArrayMgr} from "./et2_core_arrayMgr";
export class et2_customfields_list extends et2_valueWidget implements et2_IDetachedDOM, et2_IInput
{
@ -236,7 +237,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
'id': id,
'statustext': field.help,
'needed': field.needed,
'readonly': this.getArrayMgr("readonlys").isReadOnly(id, null, this.options.readonly),
'readonly':( <et2_readonlysArrayMgr> this.getArrayMgr("readonlys")).isReadOnly(id, ""+this.options.readonly),
'value': this.options.value[this.options.prefix + field_name]
});
// Can't have a required readonly, it will warn & be removed later, so avoid the warning
@ -738,6 +739,22 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
return false;
}
/**
* Display links in list as CF name
* @param field_name
* @param field
* @param attrs
*/
_setup_url( field_name, field, attrs)
{
if(this.getType() == 'customfields-list')
{
attrs.label = field.label;
}
return true;
}
/**
* Set which fields are visible, by name
*

View File

@ -318,6 +318,17 @@ var et2_url_ro = /** @class */ (function (_super_1) {
_this.setDOMNode(_this.span[0]);
return _this;
}
/**
* Set the text of the link to the label
*
* @param _value
*/
et2_url_ro.prototype.set_label = function (_value) {
this.options.label = _value;
if (this.span) {
this.span.text(_value);
}
};
et2_url_ro.prototype.set_value = function (_value) {
this.value = _value;
var link = et2_url.prototype.get_link(this.getType(), _value);
@ -326,7 +337,7 @@ var et2_url_ro = /** @class */ (function (_super_1) {
this.span.removeAttr("href");
return;
}
this.span.text(_value);
this.span.text(this.options.label || _value);
switch (this.getType()) {
case "url":
this.span.attr("href", link).attr("target", "_blank");

View File

@ -353,6 +353,20 @@ export class et2_url_ro extends et2_valueWidget
this.setDOMNode(this.span[0]);
}
/**
* Set the text of the link to the label
*
* @param _value
*/
set_label(_value)
{
this.options.label = _value;
if(this.span)
{
this.span.text(_value);
}
}
set_value(_value)
{
this.value = _value;
@ -365,7 +379,7 @@ export class et2_url_ro extends et2_valueWidget
this.span.removeAttr("href");
return;
}
this.span.text(_value);
this.span.text(this.options.label || _value);
switch(this.getType())
{
case "url":