Skip to content

Commit 7acf93a

Browse files
committed
Auto select dependencies in the UI
1 parent 49451ff commit 7acf93a

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

controller/main.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public function handle()
168168
'DESC' => $this->language->lang('SKELETON_QUESTION_COMPONENT_' . strtoupper($component) . '_UI'),
169169
'DESC_EXPLAIN' => $this->language->is_set('SKELETON_QUESTION_COMPONENT_' . strtoupper($component) . '_EXPLAIN') ? $this->language->lang('SKELETON_QUESTION_COMPONENT_' . strtoupper($component) . '_EXPLAIN') : '',
170170
'VALUE' => $this->request->variable('component_' . $component, $details['default']),
171+
'DEPENDS' => $details['dependencies'],
171172
]);
172173

173174
$this->data['components'][$component] = $this->get_user_input('component_' . $component, $details['default']);

styles/prosilver/template/editor.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@
3737
$elem.components.prop('checked', $(this).hasClass('markall'));
3838
});
3939

40+
// Auto-mark components that are dependencies
41+
$elem.components.each(function() {
42+
const $component = $(this);
43+
const depends = $component.data('depends');
44+
45+
if (!depends) {
46+
return;
47+
}
48+
49+
const dependIds = depends.split(',').map(id => id.trim());
50+
51+
$component.on('change', function() {
52+
if (this.checked) {
53+
dependIds.forEach(dependId => {
54+
const $dependency = $('#' + dependId);
55+
if ($dependency.length && !$dependency.prop('checked')) {
56+
$dependency.prop('checked', true);
57+
}
58+
});
59+
}
60+
});
61+
});
62+
4063
// Validate vendor/extension names on field blur
4164
$elem.form.on('blur', '#vendor_name, #extension_name', function() {
4265
$(this).checkNames();

styles/prosilver/template/skeleton_body.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,19 @@ <h2 class="solo">{{ lang('SKELETON_TITLE_COMPONENT_INFO') }}</h2>
8383
<h3 class="skeleton-components">{{ lang('SKELETON_COMPONENT_GROUP_' ~ group) }}</h3>
8484
{% for component in loops['component_' ~ group] %}
8585
<fieldset class="fields2">
86-
<div><span aria-label="{{ component.DESC_EXPLAIN }}" class="tooltipped tooltipped-e tooltipped-multiline"><label for="{{ component.NAME }}"><input class="components" type="checkbox" name="{{ component.NAME }}" id="{{ component.NAME }}"{% if component.VALUE %} checked="checked"{% endif %} /> <strong>{{ component.DESC }}</strong></label></span></div>
86+
<div>
87+
<span aria-label="{{ component.DESC_EXPLAIN }}" class="tooltipped tooltipped-e tooltipped-multiline">
88+
<label for="{{ component.NAME }}">
89+
<input class="components"
90+
type="checkbox"
91+
name="{{ component.NAME }}"
92+
id="{{ component.NAME }}"
93+
{% if component.VALUE %}checked="checked"{% endif %}
94+
{% if component.DEPENDS %}data-depends="{{ component.DEPENDS | map(d => 'component_' ~ d) | join(',') }}"{% endif %} />
95+
<strong>{{ component.DESC }}</strong>
96+
</label>
97+
</span>
98+
</div>
8799
</fieldset>
88100
{% endfor %}
89101
</div>

0 commit comments

Comments
 (0)