* [bug#57568] adjust app linkage for release.

This commit is contained in:
caoyanyi
2024-11-28 16:10:36 +08:00
committed by 李阳
parent ddc7593eab
commit ced2715862
2 changed files with 33 additions and 16 deletions
+23 -8
View File
@@ -1,15 +1,16 @@
window.setRelease = function(e, releaseID)
window.setRelease = function(target)
{
window.initAppPicker();
const apps = $(e.target).val();
const $releases = $('#releases' + releaseID).zui('picker');
const index = $(target).closest('tr').data('index');
const apps = $(target).val();
const $releases = $('#releases' + index).zui('picker');
$releases.$.setValue('');
const options = [];
for(let id in releases)
{
if(releases[id].system == apps) options.push({value: id, text: releases[id].name, disabled: id == releaseID});
if(releases[id].system == apps) options.push({value: id, text: releases[id].name, disabled: id == index});
}
$releases.render({items: options, required: true});
@@ -22,15 +23,20 @@ window.initAppPicker = function()
$appList.each(function()
{
const $apps = $(this);
const apps = $apps.val();
const $appsPicker = $apps.zui('picker');
const appsItems = $appsPicker.options.items;
for(i = 0; i < $apps.length; i++)
{
let value = $apps.eq(i).val();
if(value != '') selected.push(value);
}
});
$appList.each(function()
{
const $apps = $(this);
const apps = $apps.val();
const $appsPicker = $apps.zui('picker');
const appsItems = $appsPicker.options.items;
$.each(appsItems, function(i, item)
{
@@ -51,6 +57,7 @@ window.addItem = function(obj)
setTimeout(window.initAppPicker, 100);
$('#systemForm tbody tr .actions-list .btn-link').eq(1).removeClass('hidden');
if(itemIndex >= appLength - 1) $('#systemForm tbody tr .actions-list .add-item').addClass('hidden');
itemIndex ++;
};
@@ -58,7 +65,15 @@ window.addItem = function(obj)
window.deleteItem = function(obj)
{
$(obj).closest('tr').remove();
if($('#systemForm tbody tr').length < 2) $('#systemForm tbody tr .actions-list .btn-link').eq(1).addClass('hidden');
const trLen = $('#systemForm tbody tr').length;
if(trLen < 2) $('#systemForm tbody tr .actions-list .btn-link').eq(1).addClass('hidden');
if(trLen <= appLength) $('#systemForm tbody tr .actions-list .add-item').removeClass('hidden');
setTimeout(window.initAppPicker, 100);
};
$(function()
{
setTimeout(window.initAppPicker, 100);
});
+10 -8
View File
@@ -35,6 +35,7 @@ $appReleases = array();
foreach($releases as $releaseID => $release) $appReleases[$release->system][$releaseID] = $release->name;
jsVar('releases', $releases);
jsVar('appLength', count($apps));
$systemTR = array();
$i = 0;
@@ -44,6 +45,7 @@ foreach($apps as $system)
$systemTR[] = h::tr
(
setClass('form-row'),
setData('index', $i),
h::td
(
picker
@@ -52,8 +54,7 @@ foreach($apps as $system)
set::name("apps[$i]"),
set::items($apps),
$appID ? set::value($appID) : null,
set::required(true),
set('onchange', "setRelease(event, '{$i}')")
set::required(true)
)
),
h::td
@@ -73,8 +74,8 @@ foreach($apps as $system)
btnGroup
(
set::items(array(
array('class' => 'btn btn-link text-gray', 'icon' => 'plus', 'onclick' => 'addItem(this)'),
array('class' => 'btn btn-link text-gray', 'icon' => 'trash', 'onclick' => 'deleteItem(this)')
array('class' => 'btn btn-link text-gray add-item hidden', 'icon' => 'plus', 'onclick' => 'addItem(this)'),
array('class' => 'btn btn-link text-gray del-item', 'icon' => 'trash', 'onclick' => 'deleteItem(this)')
))
)
)
@@ -91,6 +92,7 @@ div
setID('systemForm'),
h::table
(
on::change('[name^=apps]')->call("setRelease", jsRaw('target')),
h::tbody
(
setClass('form'),
@@ -111,14 +113,14 @@ h::table
set::className('hidden'),
set::id('addItem'),
h::tr(
setData('index', $i),
h::td
(
picker
(
set::id("apps{$i}"),
set::name("apps[$i]"),
set::items($apps),
set('onchange', "setRelease(event, '{$i}')")
set::items($apps)
)
),
h::td
@@ -136,8 +138,8 @@ h::table
btnGroup
(
set::items(array(
array('class' => 'btn btn-link text-gray', 'icon' => 'plus', 'onclick' => 'addItem(this)'),
array('class' => 'btn btn-link text-gray', 'icon' => 'trash', 'onclick' => 'deleteItem(this)')
array('class' => 'btn btn-link text-gray add-item', 'icon' => 'plus', 'onclick' => 'addItem(this)'),
array('class' => 'btn btn-link text-gray del-item', 'icon' => 'trash', 'onclick' => 'deleteItem(this)')
))
)
)