* [bug#60727] Change parent when change lib in edit doc.
This commit is contained in:
@@ -797,10 +797,11 @@ class doc extends control
|
||||
* @param int $objectID
|
||||
* @param string $docType doc|api
|
||||
* @param int $docID
|
||||
* @param int $libID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetModules(string $objectType, int $objectID, string $docType = 'doc', int $docID = 0)
|
||||
public function ajaxGetModules(string $objectType, int $objectID, string $docType = 'doc', int $docID = 0, int $libID = 0)
|
||||
{
|
||||
if($objectType != 'mine' && empty($objectID)) return print(json_encode(array()));
|
||||
|
||||
@@ -813,18 +814,19 @@ class doc extends control
|
||||
{
|
||||
$libs = $this->doc->getApiLibs(0, $objectType, $objectID);
|
||||
$libPairs = array();
|
||||
foreach($libs as $libID => $lib) $libPairs[$libID] = $lib->name;
|
||||
foreach($libs as $lib) $libPairs[$lib->id] = $lib->name;
|
||||
}
|
||||
$libItems = array();
|
||||
foreach($libPairs as $id => $name) $libItems[] = array('text' => $name, 'value' => $id, 'keys' => $name);
|
||||
|
||||
$moduleItems = array();
|
||||
$libID = key($libPairs);
|
||||
$libID = $libID ? $libID : key($libPairs);
|
||||
if($libID)
|
||||
{
|
||||
$chapterAndDocs = $this->doc->getDocsOfLibs(array($libID), $objectType, $docID);
|
||||
$modulePairs = empty($libID) ? array() : $this->loadModel('tree')->getOptionMenu($libID, 'doc', 0);
|
||||
$moduleItems = array(0 => array('text' => '/', 'value' => 0)) + $this->doc->buildNestedDocs($chapterAndDocs, $modulePairs);
|
||||
$nestedDocs = $this->doc->buildNestedDocs($chapterAndDocs, $modulePairs);
|
||||
$moduleItems = array_merge(array(array('text' => '/', 'value' => 0)), array_values($nestedDocs));
|
||||
}
|
||||
|
||||
return print(json_encode(array('libs' => $libItems, 'modules' => $moduleItems)));
|
||||
|
||||
@@ -204,7 +204,7 @@ window.loadObjectModules = function(e, docID)
|
||||
let docType = $('.radio-primary [name=type]:not(.hidden):checked').val();
|
||||
if(typeof docType == 'undefined') docType = 'doc';
|
||||
|
||||
const link = $.createLink('doc', 'ajaxGetModules', 'objectType=' + objectType + '&objectID=' + objectID + '&type=' + docType, + '&docID=' + docID);
|
||||
const link = $.createLink('doc', 'ajaxGetModules', 'objectType=' + objectType + '&objectID=' + objectID + '&type=' + docType + '&docID=' + docID);
|
||||
$.get(link, function(data)
|
||||
{
|
||||
data = JSON.parse(data);
|
||||
@@ -218,20 +218,21 @@ window.loadObjectModules = function(e, docID)
|
||||
});
|
||||
}
|
||||
|
||||
window.loadLibModules = function(e)
|
||||
window.loadLibModules = function(e, docID)
|
||||
{
|
||||
const objectID = e.target.value;
|
||||
const libID = e.target.value;
|
||||
const libType = $(e.target.closest('div.form-group')).attr('data-lib-type');
|
||||
const objectID = $("input[name='" + libType + "']").val();
|
||||
|
||||
let docType = $('.radio-primary [name=type]:not(.hidden):checked').val();
|
||||
if(typeof docType == 'undefined') docType = 'doc';
|
||||
|
||||
const link = $.createLink('tree', 'ajaxGetOptionMenu', 'rootID=' + objectID + '&viewType=' + docType + '&branch=all&rootModuleID=0&returnType=items');
|
||||
const link = $.createLink('doc', 'ajaxGetModules', 'objectType=' + libType + '&objectID=' + objectID + '&type=' + docType + '&docID=' + docID + '&libID=' + libID);
|
||||
$.get(link, function(data)
|
||||
{
|
||||
data = JSON.parse(data);
|
||||
|
||||
const $modulePicker = $("[name='module']").zui('picker');
|
||||
$modulePicker.render({items: data});
|
||||
const $modulePicker = $("[name='parent']").zui('picker');
|
||||
$modulePicker.render({items: data.modules});
|
||||
$modulePicker.$.setValue('');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4013,7 +4013,7 @@ class docModel extends model
|
||||
}
|
||||
|
||||
$result = array();
|
||||
foreach($rootDocs as $rootDoc) $result[] = $this->buildDocItems($rootDoc->id, $rootDoc->title, $children);
|
||||
foreach($rootDocs as $rootDoc) $result[$rootDoc->id] = $this->buildDocItems($rootDoc->id, $rootDoc->title, $children);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ formPanel
|
||||
set::title($title),
|
||||
set::submitBtnText($lang->save),
|
||||
on::change('[name=space],[name=product],[name=execution]')->call('loadObjectModules', jsRaw('event'), $docID),
|
||||
on::change('[name=lib]')->call('loadLibModules', jsRaw('event')),
|
||||
on::change('[name=lib]')->call('loadLibModules', jsRaw('event'), $docID),
|
||||
on::change('[name=project]')->call('loadExecutions', jsRaw('event')),
|
||||
on::change('[name=lib],[name^=users]', "checkLibPriv('#whiteListBox', 'users')"),
|
||||
on::change('[name=lib],[name^=readUsers]', "checkLibPriv('#readListBox', 'readUsers')"),
|
||||
@@ -77,6 +77,7 @@ formPanel
|
||||
) : null,
|
||||
($modalType != 'chapter' || !$isCreate) ? formGroup
|
||||
(
|
||||
setData('libType', $objectType),
|
||||
set::width('1/2'),
|
||||
set::label($lang->doc->lib),
|
||||
set::required(true),
|
||||
|
||||
Reference in New Issue
Block a user