Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: js to vue files #1189

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const _vueInstance = new Vue({
TagPicker: () => import(/* webpackChunkName: "tag-picker" */'app/components/tag-picker/tag-picker'),
TagForm: () => import(/* webpackChunkName: "tag-form" */'app/components/tag-form/tag-form'),
FolderPicker: () => import(/* webpackChunkName: "folder-picker" */'app/components/folder-picker/folder-picker'),
Dashboard: () => import(/* webpackChunkName: "modules-index" */'app/pages/dashboard/index'),
DashboardSearch: () => import(/* webpackChunkName: "dashboard-search" */'app/components/dashboard-search'),
DateRange: () => import(/* webpackChunkName: "date-range" */'app/components/date-range/date-range'),
DateRangesView: () => import(/* webpackChunkName: "date-ranges-view" */'app/components/date-ranges-view/date-ranges-view'),
DateRangesList: () => import(/* webpackChunkName: "date-ranges-list" */'app/components/date-ranges-list/date-ranges-list'),
Expand Down
72 changes: 0 additions & 72 deletions resources/js/app/components/ajax-login/ajax-login.js

This file was deleted.

93 changes: 93 additions & 0 deletions resources/js/app/components/ajax-login/ajax-login.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<template>
<dialog class="ajax-login-modal">
<transition name="fade">
<div
class="backdrop"
@click="hide()"
v-if="isOpen"
/>
</transition>
<transition name="slide">
<div class="ajax-login">
<header>
<span
class="title"
v-if="headerText"
>
{{ headerText }}
</span>
<i
class="icon-cancel-1 has-text-size-larger"
@click="close()"
/>
</header>
<div class="content">
<div
class="message"
v-if="message"
>
{{ message }}
</div>
<iframe
title="Login form"
:src="url"
ref="iframe"
/>
</div>
</div>
</transition>
</dialog>
</template>
<script>
import Vue from 'vue';

export const AjaxLogin = Vue.extend({
name: 'AjaxLogin',

props: {
headerText: {
type: String,
default: null,
},
message: {
type: String,
default: null,
},
},

data() {
return {
isOpen: false,
url: `${BEDITA.base}/login`,
};
},

mounted() {
window.addEventListener('message', this.checkLogin);
this.isOpen = true;
},

methods: {
checkLogin(message) {
if (message.data !== 'login') {
return;
}

this.$emit('login');
this.close();
},

close() {
this.isOpen = false;
window.removeEventListener('message', this.checkLogin);

if (this.$el.parentNode) {
this.$el.parentNode.removeChild(this.$el);
}

this.$destroy();
}
},
});
export default AjaxLogin;
</script>
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
<template>
<textarea
:value="text"
@input="handleChange"
/>
</template>
<script>
import autosize from 'autosize';

export default {
props: ['value', 'reset-value'],

template: '<textarea @input="handleChange" :value="text"></textarea>',
name: 'AutosizeTextarea',
props: {
value: {
type: String,
default: '',
},
resetValue: {
type: String,
default: '',
},
},

data() {
return {
text: '',
originalValue: '',
text: {
type: String,
default: '',
},
originalValue: {
type: String,
default: '',
},
};
},

Expand All @@ -22,7 +43,7 @@ export default {

value() {
this.originalValue = this.value;
}
},
},

mounted() {
Expand All @@ -37,15 +58,10 @@ export default {
},

methods: {
/**
*
* @emits Event#input textarea value
*
* @param {Event} event event object
*/
handleChange(event) {
this.text = event.target.value;
this.$emit('input', this.text);
}
}
};
</script>
56 changes: 0 additions & 56 deletions resources/js/app/components/category-picker/category-picker.js

This file was deleted.

80 changes: 80 additions & 0 deletions resources/js/app/components/category-picker/category-picker.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<template>
<div class="category-picker">
<label
:for="id"
v-if="label"
>
{{ label }}
</label>
<Treeselect
placeholder
:form="form"
:options="categoriesOptions"
:disabled="disabled"
:disable-branch-nodes="true"
:multiple="true"
v-model="selectedIds"
@input="onChange"
/>
<input
:id="id"
type="hidden"
:form="form"
name="categories"
:value="selectedIds"
>
</div>
</template>
<script>
import { Treeselect } from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'

export default {
components: {
Treeselect,
},

props: {
id: {
type: String,
default: null,
},
categories: {
type: Array,
default: () => [],
},
disabled: Boolean,
label: {
type: String,
default: null,
},
form: {
type: String,
default: null,
},
initialCategories: {
type: Array,
default: () => [],
},
},

data() {
return {
categoriesOptions: [],
selectedIds: null,
};
},

mounted() {
this.categoriesOptions = this.categories?.map((category) => ({ id: category.id, label: category.label }));
this.selectedIds = this.initialCategories?.map(selected => this.categories.find(cat => cat.name == selected.name)?.id);
},

methods: {
onChange() {
const selectedCategories = this.categories.filter((cat) => this.selectedIds.includes(cat.id));
this.$emit('change', selectedCategories);
}
},
}
</script>
Loading
Loading