Disable channel settings on PWA

This commit is contained in:
grandeljay 2022-04-07 19:03:32 +02:00
parent 6ffdabd93b
commit bac40290d6
2 changed files with 22 additions and 2 deletions

View file

@ -25,9 +25,25 @@ $(function() {
}
});
$('.ui.dropdown').dropdown();
$('.ui.dropdown.channel').dropdown();
$('.ui.dropdown.locale').dropdown({
sortSelect : 'natural',
});
$('.ui.progress').progress();
var isPWA = window.matchMedia('(display-mode: standalone)').matches;
if (isPWA) {
$('.ui.dropdown.channel').dropdown('set selected', 'stable');
$('.ui.dropdown.channel').addClass('disabled');
$('.ui.dropdown.channel').find('select').removeAttr('name');
if ('undefined' !== typeof CHANNELS) {
CHANNELS.forEach(channel => {
if (channel.host === location.host) {
$('.ui.dropdown.channel').dropdown('set selected', channel.branch);
}
});
}
}
});

View file

@ -260,10 +260,14 @@ $page->navigation();
</div>
<?php if (defined('CHANNELS') && is_array(CHANNELS)) { ?>
<script type="text/javascript">
var CHANNELS = <?= json_encode(CHANNELS) ?>;
</script>
<div class="field">
<label><?= __('Channel') ?></label>
<select class="ui search clearable dropdown" name="user-channel">
<select class="ui search clearable dropdown channel" name="user-channel">
<option value=""><?= __('Select channel') ?></option>
<?php foreach (CHANNELS as $channel) { ?>