Skip to content

Commit

Permalink
Fix attribute tooltip for numeric (#105)
Browse files Browse the repository at this point in the history
* Fix line break for file "Numeric.js"

* Fix attribute is shown in tooltip for numeric fields
  • Loading branch information
aweichler authored Aug 3, 2023
1 parent cc80b95 commit ecaf8ab
Showing 1 changed file with 128 additions and 126 deletions.
254 changes: 128 additions & 126 deletions src/Resources/public/js/outputDataConfigElements/value/Numeric.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,130 +12,132 @@
*/


pimcore.registerNS("pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.value.Numeric");

pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.value.Numeric = Class.create(pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.Abstract, {

type: "value",
class: "Numeric",

getConfigTreeNode: function(configAttributes) {
var node = {
draggable: true,
iconCls: "pimcore_icon_" + configAttributes.dataType,
text: configAttributes.text,
configAttributes: configAttributes,
isTarget: true,
leaf: true
};

return node;
},

getCopyNode: function(source) {
var copy = source.createNode({
iconCls: source.data.iconCls,
text: source.data.text,
isTarget: true,
leaf: true,
dataType: source.data.dataType,
configAttributes: {
label: null,
type: this.type,
class: this.class,
attribute: source.data.key,
dataType: source.data.dataType
}
});
return copy;
},

getConfigDialog: function(node) {
this.node = node;

var value = "original";
if(this.node.data.configAttributes.label) {
value = "custom";
}

this.textfield = new Ext.form.TextField({
fieldLabel: t('custom_title'),
disabled: true,
length: 255,
width: 200,
value: this.node.data.text
});

this.radiogroup = new Ext.form.RadioGroup({
fieldLabel: t('config_title'),
vertical: false,
columns: 1,
value: {rb: value},
items: [
{boxLabel: t('config_title_original'), name: 'rb', inputValue: "original", checked: true},
{
boxLabel: t('config_title_custom'),
name: 'rb',
inputValue: "custom",
listeners: {
change: function(element, newValue) {
this.textfield.setDisabled(!newValue);
}.bind(this)
}
}
]
});

this.formatNumber = new Ext.form.Checkbox({
fieldLabel: t('format_number'),
length: 255,
width: 200,
checked: this.node.data.configAttributes.formatNumber
});


this.precision = new Ext.form.NumberField({
fieldLabel: t('precision'),
length: 255,
width: 200,
value: this.node.data.configAttributes.precision
});

this.configPanel = new Ext.Panel({
layout: "form",
bodyStyle: "padding: 10px;",
items: [this.radiogroup, this.textfield, this.formatNumber, this.precision],
buttons: [{
text: t("apply"),
iconCls: "pimcore_icon_apply",
handler: function () {
this.commitData();
}.bind(this)
}]
});

this.window = new Ext.Window({
width: 400,
height: 320,
modal: true,
title: t('attribute_settings'),
layout: "fit",
items: [this.configPanel]
});

this.window.show();
return this.window;
},

commitData: function() {
this.node.data.configAttributes.precision = this.precision.getValue();
this.node.data.configAttributes.formatNumber = this.formatNumber.getValue();
if(this.radiogroup.getValue().rb == "custom") {
this.node.data.configAttributes.label = this.textfield.getValue();
this.node.set('text', this.textfield.getValue());
} else {
this.node.data.configAttributes.label = null;
}
this.window.close();
}
pimcore.registerNS("pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.value.Numeric");

pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.value.Numeric = Class.create(pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.Abstract, {

type: "value",
class: "Numeric",

getConfigTreeNode: function(configAttributes) {
var node = {
draggable: true,
iconCls: "pimcore_icon_" + configAttributes.dataType,
text: configAttributes.text,
qtip: configAttributes.attribute,
configAttributes: configAttributes,
isTarget: true,
leaf: true
};

return node;
},

getCopyNode: function(source) {
var copy = source.createNode({
iconCls: source.data.iconCls,
text: source.data.text,
isTarget: true,
leaf: true,
dataType: source.data.dataType,
qtip: source.data.key,
configAttributes: {
label: null,
type: this.type,
class: this.class,
attribute: source.data.key,
dataType: source.data.dataType
}
});
return copy;
},

getConfigDialog: function(node) {
this.node = node;

var value = "original";
if(this.node.data.configAttributes.label) {
value = "custom";
}

this.textfield = new Ext.form.TextField({
fieldLabel: t('custom_title'),
disabled: true,
length: 255,
width: 200,
value: this.node.data.text
});

this.radiogroup = new Ext.form.RadioGroup({
fieldLabel: t('config_title'),
vertical: false,
columns: 1,
value: {rb: value},
items: [
{boxLabel: t('config_title_original'), name: 'rb', inputValue: "original", checked: true},
{
boxLabel: t('config_title_custom'),
name: 'rb',
inputValue: "custom",
listeners: {
change: function(element, newValue) {
this.textfield.setDisabled(!newValue);
}.bind(this)
}
}
]
});

this.formatNumber = new Ext.form.Checkbox({
fieldLabel: t('format_number'),
length: 255,
width: 200,
checked: this.node.data.configAttributes.formatNumber
});


this.precision = new Ext.form.NumberField({
fieldLabel: t('precision'),
length: 255,
width: 200,
value: this.node.data.configAttributes.precision
});

this.configPanel = new Ext.Panel({
layout: "form",
bodyStyle: "padding: 10px;",
items: [this.radiogroup, this.textfield, this.formatNumber, this.precision],
buttons: [{
text: t("apply"),
iconCls: "pimcore_icon_apply",
handler: function () {
this.commitData();
}.bind(this)
}]
});

this.window = new Ext.Window({
width: 400,
height: 320,
modal: true,
title: t('attribute_settings'),
layout: "fit",
items: [this.configPanel]
});

this.window.show();
return this.window;
},

commitData: function() {
this.node.data.configAttributes.precision = this.precision.getValue();
this.node.data.configAttributes.formatNumber = this.formatNumber.getValue();
if(this.radiogroup.getValue().rb == "custom") {
this.node.data.configAttributes.label = this.textfield.getValue();
this.node.set('text', this.textfield.getValue());
} else {
this.node.data.configAttributes.label = null;
}
this.window.close();
}
});

0 comments on commit ecaf8ab

Please sign in to comment.