Skip to content

Commit a5547ee

Browse files
committed
!410 - update
1 parent a5fbf10 commit a5547ee

File tree

7 files changed

+236
-126
lines changed

7 files changed

+236
-126
lines changed

apps/Core/Components/Devtools/Modules/ModulesComponent.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,38 @@ public function viewAction()
128128
$this->view->type = $type;
129129
$this->view->module = null;
130130

131+
$apisArr = $this->basepackages->api->init()->getAll()->api;
132+
133+
if (count($apisArr) > 0) {
134+
$repos[0]['id'] = 0;
135+
$repos[0]['name'] = 'Local Modules';
136+
$repos[0]['data']['url'] = 'https://.../';
137+
138+
foreach ($apisArr as $api) {
139+
if ($api['category'] === 'repos') {
140+
$useApi = $this->basepackages->api->useApi($api['id'], true);
141+
$apiConfig = $useApi->getApiConfig();
142+
143+
$repos[$api['id']]['id'] = $apiConfig['id'];
144+
$repos[$api['id']]['name'] = $apiConfig['name'];
145+
$repos[$api['id']]['data']['url'] = $apiConfig['repo_url'] . '/';
146+
}
147+
}
148+
}
149+
150+
$this->view->repos = $repos;
151+
$this->view->moduleTypes = $this->modulesPackage->getModuleTypes();
152+
$this->view->moduleSettings = $this->modulesPackage->getDefaultSettings($type);
153+
$this->view->moduleDependencies = $this->modulesPackage->getDefaultDependencies();
154+
131155
if ($this->getData()['id'] != 0) {
132156
if ($type === 'core') {
133157
if (is_array($coreJson['settings'])) {
158+
$this->view->moduleSettings = Json::encode($coreJson['settings']);
134159
$coreJson['settings'] = $this->modulesPackage->formatJson(['json' => $coreJson['settings']]);
135160
}
136161
if (is_array($coreJson['dependencies'])) {
162+
$this->view->moduleDependencies = Json::encode($coreJson['dependencies']);
137163
$coreJson['dependencies'] = $this->modulesPackage->formatJson(['json' => $coreJson['dependencies']]);
138164
}
139165

apps/Core/Packages/Devtools/Modules/Modules.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,52 @@ public function formatJson($data)
340340

341341
return $formatted_json;
342342
}
343+
344+
public function getModuleTypes()
345+
{
346+
return
347+
[
348+
'components' =>
349+
[
350+
'id' => 'components',
351+
'name' => 'Components'
352+
],
353+
'packages' =>
354+
[
355+
'id' => 'packages',
356+
'name' => 'Packages'
357+
],
358+
'middlewares' =>
359+
[
360+
'id' => 'middlewares',
361+
'name' => 'Middlewares'
362+
],
363+
'views' =>
364+
[
365+
'id' => 'views',
366+
'name' => 'Views'
367+
],
368+
];
369+
}
370+
371+
public function getDefaultSettings($type)
372+
{
373+
$defaultSettings = [];
374+
375+
return Json::encode($defaultSettings);
376+
}
377+
378+
public function getDefaultDependencies()
379+
{
380+
$defaultDependencies =
381+
[
382+
'components' => [],
383+
'packages' => [],
384+
'middlewares' => [],
385+
'views' => [],
386+
'external' => []
387+
];
388+
389+
return Json::encode($defaultDependencies);
390+
}
343391
}

apps/Core/Views/Default/html/devtools/modules/module.html

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
]
1818
]
1919
%}
20-
{% if module['id'] is defined %}
21-
{% set moduleDependencies = module['dependencies'] %}
22-
{% endif %}
2320
<form data-validateon="section" id="{{componentId}}-{{sectionId}}-form">
2421
<fieldset id="{{componentId}}-{{sectionId}}-fieldset">
2522
{{adminltetags.useTag('tabs',
@@ -60,16 +57,21 @@
6057
dataCollectionSection['{{componentId}}-{{sectionId}}-form'];
6158
}
6259

63-
var modules = JSON.parse('{{modulesJson}}');
64-
var moduleDependencies = JSON.parse('{{moduleDependencies}}');
60+
dataCollectionSectionForm['vars'] = { };
61+
dataCollectionSectionForm['vars']['modules'] = JSON.parse('{{modulesJson}}');
62+
dataCollectionSectionForm['vars']['moduleDependenciese'] = JSON.parse('{{moduleDependencies}}');
6563

6664
dataCollectionSection =
6765
$.extend(dataCollectionSection, {
6866
'{{componentId}}-{{sectionId}}-id' : { },
6967
'{{componentId}}-{{sectionId}}-type' : { },
7068
'{{componentId}}-{{sectionId}}-name' : { },
69+
'{{componentId}}-{{sectionId}}-display_name' : { },
7170
'{{componentId}}-{{sectionId}}-route' : { },
7271
'{{componentId}}-{{sectionId}}-description' : { },
72+
'{{componentId}}-{{sectionId}}-module_type' : {
73+
'placeholder' : 'SELECT MODULE TYPE'
74+
},
7375
'{{componentId}}-{{sectionId}}-app_type' : { },
7476
'{{componentId}}-{{sectionId}}-category' : { },
7577
'{{componentId}}-{{sectionId}}-sub_category' : { },
@@ -88,55 +90,57 @@
8890
id = e.params.data.id;
8991
label = $(e.params.data.element).parents('optgroup').attr('label').toLowerCase();
9092

91-
moduleData = modules[label][id];
93+
moduleData = dataCollectionSectionForm['vars']['modules'][label][id];
9294
$('#{{componentId}}-{{sectionId}}-dependencies-modulename').val(moduleData['name']);
9395
$('#{{componentId}}-{{sectionId}}-dependencies-moduleversion').val(moduleData['version']);
9496
$('#{{componentId}}-{{sectionId}}-dependencies-modulerepo').val(moduleData['repo']);
9597

96-
$('#{{componentId}}-{{sectionId}}-dependencies-add, #{{componentId}}-{{sectionId}}-dependencies-remove').attr('disabled', false);
98+
$('#{{componentId}}-{{sectionId}}-dependencies-add, ' +
99+
'#{{componentId}}-{{sectionId}}-dependencies-remove').attr('disabled', false);
97100
});
98101

99102
function reset() {
100-
$('#{{componentId}}-{{sectionId}}-dependencies-add, #{{componentId}}-{{sectionId}}-dependencies-remove').attr('disabled', true);
103+
$('#{{componentId}}-{{sectionId}}-dependencies-add, ' +
104+
'#{{componentId}}-{{sectionId}}-dependencies-remove').attr('disabled', true);
101105

102106
$('#{{componentId}}-{{sectionId}}-dependencies-modulename').val('');
103107
$('#{{componentId}}-{{sectionId}}-dependencies-moduleversion').val('');
104108
$('#{{componentId}}-{{sectionId}}-dependencies-modulerepo').val('');
105109
$('#{{componentId}}-{{sectionId}}-dependencies-modules').val(0).trigger('change');
106110
}
107111

108-
// function prettyfyDependencies() {
109-
// $('#{{componentId}}-{{sectionId}}-dependencies-pretty').val(JSON.stringify(moduleDependencies, null, 4));
110-
// $('#{{componentId}}-{{sectionId}}-dependencies').val(JSON.stringify(moduleDependencies));
111-
// }
112+
function prettyfyDependencies() {
113+
$('#{{componentId}}-{{sectionId}}-dependencies')
114+
.val(JSON.stringify(dataCollectionSectionForm['vars']['moduleDependenciese'], null, 4));
115+
}
112116

113117
$('#{{componentId}}-{{sectionId}}-dependencies-add').click(function(e) {
114118
e.preventDefault();
115119

116120
var found = false;
117121

118122
if (label === 'core') {
119-
moduleDependencies[label]['name'] = moduleData['name'];
120-
moduleDependencies[label]['version'] = moduleData['version'];
121-
moduleDependencies[label]['repo'] = moduleData['repo'];
123+
dataCollectionSectionForm['vars']['moduleDependenciese'][label]['name'] = moduleData['name'];
124+
dataCollectionSectionForm['vars']['moduleDependenciese'][label]['version'] = moduleData['version'];
125+
dataCollectionSectionForm['vars']['moduleDependenciese'][label]['repo'] = moduleData['repo'];
122126
} else {
123-
for (var modules in moduleDependencies) {
127+
for (var modules in dataCollectionSectionForm['vars']['moduleDependenciese']) {
124128
if (label === modules) {
125-
$.each(moduleDependencies[modules], function(index, mod) {
129+
$.each(dataCollectionSectionForm['vars']['moduleDependenciese'][modules], function(index, mod) {
126130
if (mod['name'] === moduleData['name']) {
127131
found = true;
128132
}
129133
});
130134

131135
if (!found) {
132-
moduleDependencies[modules].push(moduleData);
136+
dataCollectionSectionForm['vars']['moduleDependenciese'][modules].push(moduleData);
133137
}
134138
}
135139
}
136140
}
137141

138142
reset();
139-
// prettyfyDependencies();
143+
prettyfyDependencies();
140144
});
141145

142146
$('#{{componentId}}-{{sectionId}}-dependencies-remove').click(function(e) {
@@ -146,31 +150,31 @@
146150
var foundIndex;
147151

148152
if (label === 'core') {
149-
moduleDependencies[label]['name'] = moduleData['name'];
150-
moduleDependencies[label]['version'] = moduleData['version'];
151-
moduleDependencies[label]['repo'] = moduleData['repo'];
153+
dataCollectionSectionForm['vars']['moduleDependenciese'][label]['name'] = moduleData['name'];
154+
dataCollectionSectionForm['vars']['moduleDependenciese'][label]['version'] = moduleData['version'];
155+
dataCollectionSectionForm['vars']['moduleDependenciese'][label]['repo'] = moduleData['repo'];
152156
} else {
153-
for (var modules in moduleDependencies) {
157+
for (var modules in dataCollectionSectionForm['vars']['moduleDependenciese']) {
154158
if (label === modules) {
155-
$.each(moduleDependencies[modules], function(index, mod) {
159+
$.each(dataCollectionSectionForm['vars']['moduleDependenciese'][modules], function(index, mod) {
156160
if (mod['name'] === moduleData['name']) {
157161
found = true;
158162
foundIndex = index;
159163
}
160164
});
161165

162166
if (found) {
163-
moduleDependencies[modules].splice(foundIndex);
167+
dataCollectionSectionForm['vars']['moduleDependenciese'][modules].splice(foundIndex);
164168
}
165169
}
166170
}
167171
}
168172

169173
reset();
170-
// prettyfyDependencies();
174+
prettyfyDependencies();
171175
});
172176

173-
// prettyfyDependencies();
177+
prettyfyDependencies();
174178
}
175179
},
176180
'{{componentId}}-{{sectionId}}-dependencies-modulename' : { },

apps/Core/Views/Default/html/devtools/modules/module/dependencies.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
{% set moduleDependencies = json_encode([], 16) %}
21
{% if module['id'] is defined %}
3-
{% set moduleDependencies = module['dependencies'] %}
2+
{% set dependencies = module['dependencies'] %}
3+
{% else %}
4+
{% set dependencies = moduleDependencies %}
45
{% endif %}
56
{% if type !== 'core' %}
67
<div class="row">
@@ -144,7 +145,7 @@
144145
'fieldBazPostOnUpdate' : true,
145146
'fieldDataInputMaxLength' : 10000,
146147
'fieldTextareaRows' : 15,
147-
'fieldValue' : moduleDependencies
148+
'fieldValue' : dependencies
148149
]
149150
)}}
150151
</div>

apps/Core/Views/Default/html/devtools/modules/module/info.html

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
{% endif %}
77
{% set moduleDisplay_name = module['display_name'] %}
88
{% set moduleDescription = module['description'] %}
9+
{% set moduleModule_type = module['module_type'] %}
910
{% set moduleApp_type = module['app_type'] %}
1011
{% set moduleCategory = module['category'] %}
1112
{% set moduleSub_category = module['sub_category'] %}
1213
{% set moduleVersion = module['version'] %}
1314
{% set moduleRepo = module['repo'] %}
1415
{% set moduleClass = module['class'] %}
15-
{% set moduleSettings = module['settings'] %}
1616
{% if type === 'components' %}
1717
{% set moduleMenu_id = module['menu_id'] %}
1818
{% set moduleMenu = module['menu'] %}
@@ -24,17 +24,17 @@
2424
{% set moduleId = '' %}
2525
{% set moduleName = '' %}
2626
{% if type !== 'core' %}
27-
{% set moduleRoute = module['route'] %}
27+
{% set moduleRoute = '' %}
2828
{% endif %}
2929
{% set moduleDisplay_name = '' %}
3030
{% set moduleDescription = '' %}
31+
{% set moduleModule_type = '' %}
3132
{% set moduleApp_type = '' %}
3233
{% set moduleCategory = '' %}
3334
{% set moduleSub_category = '' %}
3435
{% set moduleVersion = '' %}
3536
{% set moduleRepo = '' %}
3637
{% set moduleClass = '' %}
37-
{% set moduleSettings = '' %}
3838
{% if type === 'components' %}
3939
{% set moduleMenu_id = '' %}
4040
{% set moduleMenu = '' %}
@@ -132,7 +132,7 @@
132132
)}}
133133
</div>
134134
{% endif %}
135-
{% if type === 'views' %}
135+
{% if type !== 'components' %}
136136
<div class="col">
137137
{{adminltetags.useTag('fields',
138138
[
@@ -141,10 +141,10 @@
141141
'componentId' : componentId,
142142
'sectionId' : sectionId,
143143
'fieldId' : 'display_name',
144-
'fieldLabel' : 'view Display name',
144+
'fieldLabel' : 'Module Display name',
145145
'fieldType' : 'input',
146146
'fieldHelp' : true,
147-
'fieldHelpTooltipContent' : 'view Display name',
147+
'fieldHelpTooltipContent' : 'Module Display name',
148148
'fieldRequired' : true,
149149
'fieldBazScan' : true,
150150
'fieldBazPostOnUpdate' : true,
@@ -181,6 +181,28 @@
181181
</div>
182182
</div>
183183
<div class="row">
184+
<div class="col">
185+
{{adminltetags.useTag('fields',
186+
[
187+
'component' : component,
188+
'componentName' : componentName,
189+
'componentId' : componentId,
190+
'sectionId' : sectionId,
191+
'fieldId' : 'module_type',
192+
'fieldLabel' : 'Module Type',
193+
'fieldType' : 'select2',
194+
'fieldHelp' : true,
195+
'fieldHelpTooltipContent' : 'Module Type',
196+
'fieldRequired' : true,
197+
'fieldBazScan' : true,
198+
'fieldDataSelect2Options' : moduleTypes,
199+
'fieldDataSelect2OptionsArray' : true,
200+
'fieldDataSelect2OptionsKey' : 'id',
201+
'fieldDataSelect2OptionsValue' : 'name',
202+
'fieldDataSelect2OptionsSelected' : moduleModule_type
203+
]
204+
)}}
205+
</div>
184206
<div class="col">
185207
{{adminltetags.useTag('fields',
186208
[

apps/Core/Views/Default/html/devtools/modules/module/settings.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
{% if module['id'] is defined %}
2+
{% set settings = module['settings'] %}
3+
{% else %}
4+
{% set settings = moduleSettings %}
5+
{% endif %}
16
<div class="row">
27
<div class="col">
38
{{adminltetags.useTag('fields',
@@ -17,7 +22,7 @@
1722
'fieldBazPostOnUpdate' : true,
1823
'fieldDataInputMaxLength' : 1024,
1924
'fieldTextareaRows' : 15,
20-
'fieldValue' : moduleSettings
25+
'fieldValue' : settings
2126
]
2227
)}}
2328
</div>

0 commit comments

Comments
 (0)