Skip to content

Commit 32b0e17

Browse files
committed
!410 - Fixed minor bugs related to module type views public repo.
1 parent 6a28ee0 commit 32b0e17

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

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

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function addModule($data)
143143

144144
try {
145145
if ($this->modules->{$data['module_type']}->add($data) &&
146-
$this->updateModuleJson($data) &&
146+
$this->updateModuleJson($data, false, true) &&
147147
$this->generateNewFiles($data)
148148
) {
149149
if ($data['createrepo'] == true) {
@@ -278,7 +278,7 @@ public function updateModule($data)
278278
$module = array_merge($module, $data);
279279

280280
if ($this->modules->{$data['module_type']}->update($module) &&
281-
$this->updateModuleJson($data)
281+
$this->updateModuleJson($data, false, true)
282282
) {
283283
if ($data['module_type'] === 'components') {
284284
$this->addUpdateComponentMenu($data);
@@ -300,17 +300,41 @@ public function updateModule($data)
300300
}
301301

302302
if ($data['createrepo'] == true && strtolower($data['name']) !== 'core') {
303-
if (!$this->checkRepo($data)) {
304-
$newRepo = $this->createRepo($data);
303+
if ($data['module_type'] === 'views' && $data['base_view_module_id'] == 0) {//Create public repository as well
304+
if (!$this->checkRepo($data)) {
305+
$newRepo['base'] = $this->createRepo($data);
306+
}
307+
308+
$data['repo'] = $data['repo'] . '-public';
309+
if (!$this->checkRepo($data)) {
310+
$newRepo['public'] = $this->createRepo($data);
311+
}
305312

306313
$this->addResponse('Module updated & created new repo.',
307314
0,
308315
[
316+
'newFiles' => $this->newFiles,
317+
'newDirs' => $this->newDirs,
309318
'newRepo' => $newRepo
310319
]
311320
);
312321

313322
return;
323+
} else {
324+
if (!$this->checkRepo($data)) {
325+
$newRepo = $this->createRepo($data);
326+
327+
$this->addResponse('Module updated & created new repo.',
328+
0,
329+
[
330+
'newFiles' => $this->newFiles,
331+
'newDirs' => $this->newDirs,
332+
'newRepo' => $newRepo
333+
]
334+
);
335+
336+
return;
337+
}
314338
}
315339
}
316340

@@ -657,7 +681,7 @@ protected function updateModuleJson($data, $viaGenerateRelease = false, $viewPub
657681
try {
658682
$this->localContent->write($jsonFile, $jsonContent);
659683

660-
if ($viewPublic) {
684+
if ($data['module_type'] === 'views' && $viewPublic) {
661685
$jsonFile = $this->getNewFilesLocation($data, true);
662686

663687
if (!str_contains($data['repo'], '-public')) {
@@ -2025,7 +2049,11 @@ public function generateRelease($data)
20252049
} else {
20262050
$reposArr = [$module['repo']];
20272051

2028-
$fileLocation = explode('/Install/', $this->getModuleJsonFileLocation($module));
2052+
if ($data['module_type'] === 'views') {
2053+
$fileLocation = explode('/Default/', $this->getModuleJsonFileLocation($module));
2054+
} else {
2055+
$fileLocation = explode('/Install/', $this->getModuleJsonFileLocation($module));
2056+
}
20292057

20302058
if (count($fileLocation) > 1) {
20312059
$fileLocation = $data['module_type'] === 'views' ? 'view.json' : 'Install/' . $fileLocation[1];
@@ -2123,8 +2151,8 @@ public function generateRelease($data)
21232151

21242152
if (isset($data['module_type']) &&
21252153
$data['module_type'] === 'views' &&
2126-
isset($data['base_view_module_id']) &&
2127-
$data['base_view_module_id'] == 0
2154+
isset($module['base_view_module_id']) &&
2155+
$module['base_view_module_id'] == 0
21282156
) {
21292157
array_push($reposArr, $module['repo'] . '-public');
21302158
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,10 +3000,12 @@
30003000
'#{{componentId}}-{{sectionId}}-dependencies-external-add').click(function(e) {
30013001
e.preventDefault();
30023002

3003-
if ($('#{{componentId}}-{{sectionId}}-dependencies-external-version').val() === '') {
3004-
$('#{{componentId}}-{{sectionId}}-dependencies-external-version').val('^0');
3005-
} else if (!$('#{{componentId}}-{{sectionId}}-dependencies-external-version').val().startsWith('^')) {
3006-
$('#{{componentId}}-{{sectionId}}-dependencies-external-version').val('^' + $('#{{componentId}}-{{sectionId}}-dependencies-external-version').val());
3003+
if ($('#{{componentId}}-{{sectionId}}-dependencies-external-version').length > 0) {
3004+
if ($('#{{componentId}}-{{sectionId}}-dependencies-external-version').val() === '') {
3005+
$('#{{componentId}}-{{sectionId}}-dependencies-external-version').val('^0');
3006+
} else if (!$('#{{componentId}}-{{sectionId}}-dependencies-external-version').val().startsWith('^')) {
3007+
$('#{{componentId}}-{{sectionId}}-dependencies-external-version').val('^' + $('#{{componentId}}-{{sectionId}}-dependencies-external-version').val());
3008+
}
30073009
}
30083010

30093011
var found = false;
@@ -3046,7 +3048,7 @@
30463048
if (!found) {
30473049
if (modules === 'views' && dataCollectionSectionForm['vars']['module_type'] === 'views') {
30483050
if (dataCollectionSectionForm['vars']['modules'][modules][moduleData['id']]['base_view_module_id'] != '0') {
3049-
PNotify.error({'text': 'Only base view modules can be a view dependency'});
3051+
PNotify.error({'text': 'Only non base view modules can be a view dependency'});
30503052

30513053
reset();
30523054

0 commit comments

Comments
 (0)