Skip to content

Commit 14a0af9

Browse files
committed
MAGETWO-89383: Introduce Url input ui component
1 parent 4b0e30c commit 14a0af9

File tree

5 files changed

+30
-46
lines changed

5 files changed

+30
-46
lines changed

app/code/Magento/Ui/view/base/web/js/form/element/url-input.js

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ define([
2525
isDisplayAdditionalSettings: true,
2626
settingValue: false,
2727
settingLabel: $t('Open in new tab'),
28+
2829
//observable object(without functional call)
2930
tracks: {
3031
linkedElement: true
@@ -37,16 +38,29 @@ define([
3738
}
3839
},
3940
listens: {
40-
checked: 'updateSettingValue',
41-
disabled: 'hideLinkedElement'
41+
checked: 'settingValue',
42+
disabled: 'hideLinkedElement',
43+
settingValue: 'checked',
44+
linkType: 'createChildUrlInputComponent'
4245
},
4346
links: {
4447
linkType: '${$.provider}:${$.dataScope}.type',
45-
settingValue: '${$.provider}:${$.dataScope}.setting',
46-
value: false
48+
settingValue: '${$.provider}:${$.dataScope}.setting'
4749
}
4850
},
4951

52+
/**
53+
*
54+
* @inheritdoc
55+
*/
56+
initialize: function () {
57+
58+
this._super()
59+
.setOptions();
60+
61+
return this;
62+
},
63+
5064
/**
5165
* Initializes observable properties of instance
5266
*
@@ -55,8 +69,7 @@ define([
5569
initObservable: function () {
5670
this._super()
5771
.observe('componentTemplate options value linkType settingValue checked isDisplayAdditionalSettings')
58-
.processLinkTypes()
59-
.setOptions();
72+
.processLinkTypes();
6073

6174
return this;
6275
},
@@ -135,35 +148,6 @@ define([
135148
this._super();
136149
},
137150

138-
/**
139-
* Set url setting value to datasource
140-
*
141-
* @param {Boolean} checked
142-
*
143-
* @return void
144-
*/
145-
updateSettingValue: function (checked) {
146-
this.source.set(this.dataScope + '.setting', checked);
147-
},
148-
149-
/**
150-
* Initialize linked input field based on linked type
151-
*
152-
* @param {String} value
153-
*
154-
* @return void
155-
*/
156-
setDifferedFromDefault: function (value) {
157-
this._super();
158-
159-
if (!_.isUndefined(value) && value) {
160-
this.createChildUrlInputComponent(value);
161-
//to store current element
162-
this.linkedElement = this.linkedElementInstances[value];
163-
this.linkType(value);
164-
}
165-
},
166-
167151
/**
168152
* Create child component by value
169153
*
@@ -178,6 +162,8 @@ define([
178162
layout([elementConfig]);
179163
this.linkedElementInstances[value] = this.requestModule(elementConfig.name);
180164
}
165+
this.linkedElement = this.linkedElementInstances[value];
166+
181167
},
182168

183169
/**

app/code/Magento/Ui/view/base/web/templates/form/element/url-input.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
<label class="admin__field-label" if="$data.label" visible="$data.labelVisible" attr="for: uid">
1212
<span translate="label" attr="'data-config-scope': $data.scopeLabel"/>
1313
</label>
14-
<div class="admin__field-control url-input-element"
14+
<div class="admin__field-control"
1515
css="'_with-tooltip': $data.tooltip, '_with-reset': $data.showFallbackReset && $data.isDifferedFromDefault">
1616

17-
<div>
1817
<!--render link types select-->
1918
<render args="typeSelectorTemplate"/>
2019

@@ -23,7 +22,6 @@
2322
<render/>
2423
<label class="admin__field-error" visible="error" attr="for: uid" text="error"/>
2524
</div>
26-
</div>
2725

2826
<!--display container to specify url options(Example: open in new tab)-->
2927
<div render="settingTemplate" if="isDisplayAdditionalSettings"/>

app/code/Magento/Ui/view/base/web/templates/form/element/urlInput/setting.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class="admin__control-checkbox"
1111
ko-checked="$data.checked"
1212
disable="disabled"
13-
ko-value="value"
13+
ko-value="settingValue"
1414
hasFocus="focused"
1515
attr="id: uid, name: inputName"/>
1616

app/code/Magento/Ui/view/base/web/templates/form/element/urlInput/typeSelector.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
},
1515
hasFocus: focused,
1616
optgroup: options,
17-
value: value,
17+
value: linkType,
1818
optionsValue: 'value',
1919
optionsText: 'label'"/>

app/design/adminhtml/Magento/backend/web/css/source/components/_url_input.less

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
//
77
// Components -> Url Input
88
// _____________________________________________
9-
.url-input-container .url-input-element {
10-
& > div:after {
11-
clear: both;
12-
}
9+
.url-input-container {
1310

1411
.url-input-select {
1512
float: left;
16-
margin-right: 20px;
13+
max-width: 7.5em;
14+
min-width: 7.5em;
1715
}
1816

1917
.url-input-setting {
@@ -27,7 +25,9 @@
2725

2826
.url-input-element-linked-element {
2927
float: left;
30-
max-width: 200px;
28+
margin-left: 1.5em;
29+
max-width: calc(79%);
30+
min-width: calc(79%);
3131
}
3232
}
3333

0 commit comments

Comments
 (0)