Skip to content

Commit

Permalink
Merge pull request 'some bugfixes and cleanup' (#154) from 6.x-cleanu…
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Ammann committed Nov 23, 2020
2 parents 4ac49a1 + 3369dcb commit f2138d0
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 362 deletions.
8 changes: 7 additions & 1 deletion app/Http/Middleware/CheckIfControllerIsEnabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ class CheckIfControllerIsEnabled
*/
public function handle($request, Closure $next)
{
if (!$request->route()->controller::isEnabled()) {
$controller = $request->route()->controller;

if (!method_exists($controller, 'isEnabled')) {
return $next($request);
}

if (!$controller::isEnabled()) {
abort(404);
}

Expand Down
2 changes: 1 addition & 1 deletion resources/js/modules/ApiClient/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class Auth extends ApiClient {
await this.post(`${this.url}/login`, data);
}

public async logout(): Promise<void> {
public logout(): Promise<void> {
return this.post(`${this.url}/logout`);
}

Expand Down
7 changes: 2 additions & 5 deletions resources/js/store/modules/recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ const actions = {
async show({ state }, { id }) {
return state.data.filter(recipe => recipe.id === id)[0];
},
async remove({ state, commit }, { id, alreadyDeleted = false }) {
async remove({ commit }, { id }) {
await new Recipes().remove(id);

if (state.data && state.data.length) {
commit('changeValue', { id, property: 'deleted_at', value: new Date().toJSON() });
}
commit('changeValue', { id, property: 'deleted_at', value: new Date().toJSON() });
},
async restore({ commit }, { id }) {
await new Recipes().restore(id);
Expand Down
69 changes: 51 additions & 18 deletions resources/js/views/Account/Index.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
<template>
<div class="columns">
<div class="column is-one-third">
<h3 class="title">{{ $t('Details') }}</h3>
<h3 class="title">{{ $t("Details") }}</h3>
<table>
<tr>
<th>{{ $t('Name') }}:</th>
<th>{{ $t("Name") }}:</th>
<td>{{ user.name }}</td>
</tr>
<tr>
<th>{{ $t('Email') }}:</th>
<th>{{ $t("Email") }}:</th>
<td>{{ user.email }}</td>
</tr>
<tr>
<th>{{ $t('Signed Up') }}:</th>
<td :title="$moment(user.created_at)">{{ $moment(user.created_at).from() }}</td>
<th>{{ $t("Signed Up") }}:</th>
<td :title="$moment(user.created_at)">
{{ $moment(user.created_at).from() }}
</td>
</tr>
<tr>
<th>{{ $t('Last change') }}:</th>
<td :title="$moment(user.updated_at)">{{ $moment(user.updated_at).from() }}</td>
<th>{{ $t("Last change") }}:</th>
<td :title="$moment(user.updated_at)">
{{ $moment(user.updated_at).from() }}
</td>
</tr>
<tr>
<span v-if="user.admin" class="tag is-info">{{ $t('You\'re admin') }}</span>
<span v-if="user.admin" class="tag is-info">
{{ $t("You're admin") }}
</span>
</tr>
</table>
</div>
Expand All @@ -29,24 +35,40 @@
<h3
@click.prevent="$router.push({ name: 'recipes.add' })"
class="title add-cursor"
>{{ user.admin ? $t('All recipes') : $t('Your recipes') }}</h3>
<ul>
>
{{ user.admin ? $t("All recipes") : $t("Your recipes") }}
</h3>
<p v-if="!this.sortedRecipes.length">
<span>{{ $t("Seems a bit empty here...") }}</span>
<router-link :to="{ name: 'recipes.add' }">
{{ $t("Click here to create a recipe") }}
</router-link>
</p>
<ul v-else>
<li :key="recipe.id" v-for="recipe in sortedRecipes">
<span v-if="!recipe.deleted_at">
<button
@click.prevent="$store.dispatch('recipes/remove', { id: recipe.id })"
@click.prevent="
$store.dispatch('recipes/remove', { id: recipe.id })
"
class="button is-white is-small"
>
<i class="fas fa-trash"></i>
</button>
<router-link
tag="a"
:to="{ name:'recipes', params: {id: recipe.id, slug: recipe.slug} }"
>{{ recipe.name }}</router-link>
:to="{
name: 'recipes',
params: { id: recipe.id, slug: recipe.slug }
}"
>{{ recipe.name }}</router-link
>
</span>
<span v-else>
<button
@click.prevent="$store.dispatch('recipes/restore', { id: recipe.id })"
@click.prevent="
$store.dispatch('recipes/restore', { id: recipe.id })
"
class="button is-white is-small"
>
<i class="fas fa-redo"></i>
Expand All @@ -70,8 +92,16 @@
<h3
@click.prevent="$router.push({ name: 'cookbooks.add' })"
class="title add-cursor"
>{{ user.admin ? $t('All cookbooks') : $t('Your cookbooks') }}</h3>
<ul>
>
{{ user.admin ? $t("All cookbooks") : $t("Your cookbooks") }}
</h3>
<p v-if="!this.sortedCookbooks.length">
<span>{{ $t("Seems a bit empty here...") }}</span>
<router-link :to="{ name: 'cookbooks.add' }">
{{ $t("Click here to create a cookbook") }}
</router-link>
</p>
<ul v-else>
<li :key="cookbook.id" v-for="cookbook in sortedCookbooks">
<span>
<button
Expand All @@ -88,7 +118,10 @@
>
<i class="fas fa-redo"></i>
</button>
<button @click.prevent="editCookbook(cookbook)" class="button is-white is-small">
<button
@click.prevent="editCookbook(cookbook)"
class="button is-white is-small"
>
<i class="fas fa-edit"></i>
</button>
{{ cookbook.name }}
Expand Down Expand Up @@ -153,7 +186,7 @@ export default {
if (!this.loggedIn) {
this.$router.push({ name: "home" });
} else if (!this.user.has_verified_email) {
this.$router.push({ name: "verify.email" });
this.$router.push({ name: "email.verify" });
}
this.loadRecipes(1, false);
Expand Down
2 changes: 1 addition & 1 deletion resources/js/views/Admin/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default {
if (!this.loggedIn || !this.user.admin) {
this.$router.push({ name: "home" });
} else if (!this.user.has_verified_email) {
this.$router.push({ name: "verify.email" });
this.$router.push({ name: "email.verify" });
}
this.load();
Expand Down
9 changes: 7 additions & 2 deletions resources/js/views/Auth/VerifyEmail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ export default {
})
},
created() {
setTimeout(() => {
if (this.user.has_verified_email) {
this.$buefy.snackbar.open("Your email address is already verified.");
this.$router.push({ name: "home" });
}
}, 200);
if (!this.loggedIn) {
this.$router.push({ name: "home" });
} else if (this.user.has_verified_email) {
this.$router.push({ name: "home" });
}
}
};
Expand Down
14 changes: 9 additions & 5 deletions resources/js/views/Cookbook/Add.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<form class="columns" @submit.prevent="submit">
<div class="column is-one-third is-offset-3">
<h1 class="title has-text-centered">{{ $t('Add cookbook') }}</h1>
<div
class="column is-full-mobile is-full-tablet is-three-fifths-desktop is-offset-one-fifth-desktop"
>
<h1 class="title has-text-centered">{{ $t("Add cookbook") }}</h1>

<br />

Expand All @@ -17,9 +19,11 @@
/>

<rm-submit-button>
{{ $t('Add') }}
{{ $t("Add") }}
<template v-slot:buttons>
<b-button @click="$router.go(-1)" type="is-danger">{{ $t('Cancel') }}</b-button>
<b-button @click="$router.go(-1)" type="is-danger">
{{ $t("Cancel") }}
</b-button>
</template>
</rm-submit-button>
</div>
Expand Down Expand Up @@ -52,7 +56,7 @@ export default {
if (!this.loggedIn) {
this.$router.push({ name: "home" });
} else if (!this.user.has_verified_email) {
this.$router.push({ name: "verify.email" });
this.$router.push({ name: "email.verify" });
}
}, 1000);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default {
if (!this.loggedIn) {
this.$router.push({ name: "home" });
} else if (!this.user.has_verified_email) {
this.$router.push({ name: "verify.email" });
this.$router.push({ name: "email.verify" });
}
}, 1000);
Expand Down
103 changes: 0 additions & 103 deletions resources/js/views/Recipe/Add/Infos.vue

This file was deleted.

Loading

0 comments on commit f2138d0

Please sign in to comment.