Skip to content

Commit

Permalink
Splitting Draft et Active bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
axeloz committed May 17, 2023
1 parent dc70bd9 commit 47fa3cb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
5 changes: 2 additions & 3 deletions lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
'authentication' => 'Authentication',
'login' => 'Username',
'password' => 'Password',
'do-login' => 'Login now'


'do-login' => 'Login now',
'pending' => 'Drafts',
];
5 changes: 2 additions & 3 deletions lang/fr/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
'authentication' => 'Authentification',
'login' => 'Identifiant',
'password' => 'Mot de passe',
'do-login' => 'S\'authentifier'


'do-login' => 'S\'authentifier',
'pending' => 'Brouillons',
];
30 changes: 22 additions & 8 deletions resources/views/homepage.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
document.addEventListener('alpine:init', () => {
Alpine.data('bundle', () => ({
bundles: null,
active: null,
expired: null,
pending: [],
active: [],
expired: [],
currentBundle: null,
init: function() {
Expand All @@ -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()
})
}
Expand Down Expand Up @@ -124,18 +130,26 @@ class="w-full py-4 text-slate-700 bg-transparent h-8 p-0 py-1 border-b border-pr
>
<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>

<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>
Expand Down

0 comments on commit 47fa3cb

Please sign in to comment.