Splitting Draft et Active bundles

This commit is contained in:
Axel 2023-05-17 13:54:58 +02:00
parent dc70bd9650
commit 47fa3cb3f3
Signed by: axel
GPG key ID: 73C0A5961B6BC740
3 changed files with 26 additions and 14 deletions

View file

@ -79,7 +79,6 @@ return [
'authentication' => 'Authentication',
'login' => 'Username',
'password' => 'Password',
'do-login' => 'Login now'
'do-login' => 'Login now',
'pending' => 'Drafts',
];

View file

@ -79,7 +79,6 @@ return [
'authentication' => 'Authentification',
'login' => 'Identifiant',
'password' => 'Mot de passe',
'do-login' => 'S\'authentifier'
'do-login' => 'S\'authentifier',
'pending' => 'Brouillons',
];

View file

@ -6,8 +6,9 @@
document.addEventListener('alpine:init', () => {
Alpine.data('bundle', () => ({
bundles: null,
active: null,
expired: null,
pending: [],
active: [],
expired: [],
currentBundle: null,
init: function() {
@ -17,20 +18,25 @@
this.bundles = JSON.parse(bundles)
if (this.bundles != null && Object.keys(this.bundles).length > 0) {
this.active = []
this.expired = []
this.bundles.forEach( (bundle) => {
if (bundle.title == null || bundle.title == '') {
bundle.title = 'untitled'
bundle.label = 'untitled'
}
else {
bundle.label = bundle.title
}
if (bundle.expires_at != null && moment.unix(bundle.expires_at).isBefore(moment())) {
this.expired.push(bundle)
}
else {
else if (bundle.completed == true) {
this.active.push(bundle)
}
else {
this.pending.push(bundle)
}
bundle.label += ' - {{ __('app.created-at') }} '+moment.unix(bundle.created_at).fromNow()
})
}
@ -124,10 +130,18 @@
>
<option>-</option>
<template x-if="Object.keys(pending).length > 0">
<optgroup label="{{ __('app.pending') }}">
<template x-for="bundle in pending">
<option :value="bundle.bundle_id" x-text="bundle.label"></option>
</template>
</optgroup>
</template>
<template x-if="Object.keys(active).length > 0">
<optgroup label="{{ __('app.active') }}">
<template x-for="bundle in active">
<option :value="bundle.bundle_id" x-text="bundle.title"></option>
<option :value="bundle.bundle_id" x-text="bundle.label"></option>
</template>
</optgroup>
</template>
@ -135,7 +149,7 @@
<template x-if="Object.keys(expired).length > 0">
<optgroup label="{{ __('app.expired') }}">
<template x-for="bundle in expired">
<option :value="bundle.bundle_id" x-text="bundle.title"></option>
<option :value="bundle.bundle_id" x-text="bundle.label"></option>
</template>
</optgroup>
</template>