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

Vue.js 3 upgrade #2561

Draft
wants to merge 31 commits into
base: 3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
667631d
Updated deprecated named slot syntax to the latest syntax
zeezo887 Mar 27, 2024
104ab9e
Merge branch '3.x' into vue3-migration
zeezo887 Mar 27, 2024
8768645
update vue to 3.1, install @vue/compat and replace vue-template-compi…
zeezo887 Mar 29, 2024
359d1c8
set vue alias to @vue/compat and enable compat mode
zeezo887 Mar 29, 2024
6ea96e0
remove functional from template
zeezo887 Mar 29, 2024
781f364
add key attribute to template
zeezo887 Mar 29, 2024
6c103d5
removed vue filters, suppressed console.error warnings, removed .nati…
zeezo887 Apr 1, 2024
2e56faf
wip: Update app entry to use new global mounting API and updated vuex…
zeezo887 Apr 3, 2024
3c307be
fixed $trans and openMediaLibrary
zeezo887 Apr 4, 2024
fa6dd8b
added no console rule-name to suppress console warnings
zeezo887 Apr 8, 2024
7686505
updated tiptap to @tiptap/vue-3
zeezo887 Apr 8, 2024
32fcbf8
changed beforeDestroy to beforeUnmount
zeezo887 Apr 8, 2024
45c2b52
added whitespace config and updated bind and inserted to beforeMount …
zeezo887 Apr 8, 2024
ace3a6e
updated vue-timeago to vue-timeago3 and date-fns to v3.6.0
zeezo887 Apr 12, 2024
b19b85f
removed Vue.set, Vue.delete, updated render fn in Button component an…
zeezo887 Apr 15, 2024
3a55dfe
removed unused vue import
zeezo887 Apr 17, 2024
eb902f5
updated vuetrend, vue-select
zeezo887 Apr 17, 2024
5b6a776
updated vuedraggable
zeezo887 Apr 18, 2024
b595014
changed $scopedSlots to $slots and pass props into default value func…
zeezo887 Apr 18, 2024
7b24e02
removed vue compat
zeezo887 Apr 22, 2024
978f240
fixed a17-button triggering twice and some styling issues related to …
zeezo887 Apr 22, 2024
e4b8628
stop input event from propagating to parent
zeezo887 Apr 25, 2024
246c00d
fix create button disable property
zeezo887 Apr 25, 2024
35eea56
use new v-model syntax for v-select
zeezo887 Apr 25, 2024
169e7b7
disable detailed warnings for hydration mismatches
zeezo887 Apr 25, 2024
3a681a4
documented events emitted on some components
zeezo887 Apr 26, 2024
f234cb9
Merge branch '3.x' into vue3-migration
zeezo887 Apr 26, 2024
75ea24d
fix: drag and drop dragging all items in blocks and repeater
zeezo887 May 14, 2024
8225648
defined emits and fixed form fields not rendering in blocks inside "E…
zeezo887 May 15, 2024
174c992
fixed weird separator line
zeezo887 May 16, 2024
618783b
define components events with emits option
zeezo887 May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions frontend/js/behaviors/openMediaLibrary.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import forEachNodelist from '../utils/forEachNodelist.js'
// Open Media library from the nav

const openMediaLibrary = function () {
const openMediaLibrary = function (app) {
const bts = document.querySelectorAll('[data-medialib-btn]')

function _triggerOpenMediaLibrary () {
if (window[process.env.VUE_APP_NAME].vm) {
window[process.env.VUE_APP_NAME].vm.openFreeMediaLibrary()
}
app.openFreeMediaLibrary()
}

// Toggle Click button
Expand Down
12 changes: 7 additions & 5 deletions frontend/js/components/Browser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
</div>
<div class="browser__search">
<a17-filter @submit="submitFilter">
<div slot="additional-actions" v-if="browserNote">
<span class="browser__note f--small">
{{ browserNote }}
</span>
</div>
<template v-slot:additional-actions>
Copy link
Contributor

@Tofandel Tofandel Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use #additional-actions instead of v-slot which I personnally find easier to read and recognize it as a slot

<div v-if="browserNote">
<span class="browser__note f--small">
{{ browserNote }}
</span>
</div>
</template>
</a17-filter>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/components/BrowserField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</template>

<script>
import draggable from 'vuedraggable'
import { VueDraggableNext } from 'vue-draggable-next'
import { mapGetters,mapState } from 'vuex'

import draggableMixin from '@/mixins/draggable'
Expand All @@ -49,7 +49,7 @@
name: 'A17BrowserField',
components: {
'a17-browseritem': Browseritem,
draggable
draggable: VueDraggableNext
},
mixins: [draggableMixin],
props: {
Expand Down
1 change: 1 addition & 0 deletions frontend/js/components/BrowserItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<script>
export default {
name: 'A17BrowserItem',
emits: ['delete'],
props: {
name: {
type: String,
Expand Down
36 changes: 18 additions & 18 deletions frontend/js/components/Button.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<script>
import { h } from 'vue'

export default {
name: 'A17Button',
emits: ['click'],
props: {
el: {
type: String,
Expand Down Expand Up @@ -64,44 +67,41 @@
this.$emit('click')
}
},
render: function (createElement) {
render: function () {
const elOpts = {
class: this.buttonClasses,
attrs: {},
on: {
click: (event) => {
this.onClick(event)
}
onClick: (event) => {
this.onClick(event)
}
}

// button
if (this.el === 'button') {
elOpts.attrs.type = this.type
elOpts.type = this.type

if (this.disabled) {
elOpts.attrs.disabled = this.disabled
elOpts.disabled = this.disabled
}
}

// a:href
if (this.el === 'a' && this.href) {
elOpts.attrs.href = this.href
elOpts.href = this.href

if (this.target) {
elOpts.attrs.target = this.target
elOpts.target = this.target
}

if (this.download) {
elOpts.attrs.download = this.download
elOpts.download = this.download
}

if (this.rel) {
elOpts.attrs.rel = this.rel
elOpts.rel = this.rel
}
}

return createElement(this.el, elOpts, this.$slots.default)
return h(this.el, elOpts, this.$slots.default())
}
}
</script>
Expand Down Expand Up @@ -184,7 +184,7 @@
font-weight:600;
padding: 0 15px;

.icon {
:deep(.icon) {
vertical-align: baseline;
top: 3px;
position: relative;
Expand Down Expand Up @@ -383,7 +383,7 @@
color: $color__icons;
@include monospaced-figures('off'); // dont use monospaced figures here

.icon {
:deep(.icon) {
transition: color .25s linear;
}

Expand All @@ -392,12 +392,12 @@
border-color: $color__text;
color: $color__text;

.icon {
:deep(.icon) {
color: $color__text;
}
}

.icon {
:deep(.icon) {
// vertical-align: top;
// height: 100%;
display: block;
Expand All @@ -421,7 +421,7 @@
color: $color__button_greyed;
background: $color__button_greyed--bg;

.icon {
:deep(.icon) {
color: $color__button_greyed;
}

Expand Down
12 changes: 6 additions & 6 deletions frontend/js/components/ButtonBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
border-radius: 2px;
display: flex;

> a,
> button {
> :slotted(a),
> :slotted(button) {
@include btn-reset;
height: $toolbar__height - 2px;
line-height: $toolbar__height - 2px;
Expand Down Expand Up @@ -80,14 +80,14 @@
}
}

> a:first-child,
> button:first-child {
> :slotted(a):first-child,
> :slotted(button):first-child {
border-top-left-radius: $border__radius;
border-bottom-left-radius: $border__radius;
}

> a:last-child,
> button:last-child {
> :slotted(a):last-child,
> :slotted(button):last-child {
border-top-right-radius: $border__radius;
border-bottom-right-radius: $border__radius;
border-right: 0 none;
Expand Down
1 change: 1 addition & 0 deletions frontend/js/components/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
export default {
name: 'A17Checkbox',
mixins: [randKeyMixin],
emits: ['change'],
props: {
value: {
default: ''
Expand Down
9 changes: 7 additions & 2 deletions frontend/js/components/CheckboxAccordion.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<template>
<a17-accordion :open="open" @toggleVisibility="notifyOpen">
<span slot="accordion__title"><slot></slot></span>
<div slot="accordion__value">{{ currentLabel }}</div>
<template v-slot:accordion__title>
<span><slot></slot></span>
</template>
<template v-slot:accordion__value>
<div>{{ currentLabel }}</div>
</template>
<a17-checkboxgroup :name="name" :options="options" @change="changeValue" :selected="currentValue" :min="1"></a17-checkboxgroup>
</a17-accordion>
</template>
Expand All @@ -18,6 +22,7 @@
'a17-accordion': a17Accordion
},
mixins: [VisibilityMixin],
emits: ['open'],
props: {
value: {
default: function () { return [] }
Expand Down
5 changes: 5 additions & 0 deletions frontend/js/components/CheckboxGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
default: function () { return [] }
}
},
data () {
return {
hasLocale: false
}
},
mixins: [InputframeMixin, CheckboxMixin, FormStoreMixin],
computed: {
checkboxClasses: function () {
Expand Down
8 changes: 5 additions & 3 deletions frontend/js/components/ColorField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
/>
<a17-dropdown ref="colorDropdown" class="form__field--color" position="bottom-right" :arrow="true" :offset="15" :minWidth="300" :clickable="true" :sideOffset="15" @close="saveIntoStore">
<span class="form__field--colorBtn" :style="bcgStyle" @click="$refs.colorDropdown.toggle()"></span>
<div slot="dropdown__content">
<a17-colorpicker :color="value" @change="updateValueFromPicker"></a17-colorpicker>
</div>
<template v-slot:dropdown__content>
<div>
<a17-colorpicker :color="value" @change="updateValueFromPicker"></a17-colorpicker>
</div>
</template>
</a17-dropdown>
</div>
</a17-inputframe>
Expand Down
1 change: 1 addition & 0 deletions frontend/js/components/ColorPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

export default {
name: 'a17ColorPicker',
emits: ['change'],
props: {
color: {
type: String,
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/components/ConnectorField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
toggleVisibility: function (value) {

if (this.$refs.fieldContainer) {
this.$slots.default.forEach((child) => {
this.$slots.default().forEach((child) => {
// Base input fields.
if (
child.componentInstance !== undefined &&
Expand All @@ -100,7 +100,7 @@
child.componentInstance.$slots !== undefined &&
child.componentInstance.$slots.default !== undefined
) {
child.componentInstance.$slots.default.forEach((subChild) => {
child.componentInstance.$slots.default().forEach((subChild) => {
if (subChild.componentInstance && subChild.componentInstance.destroyValue) {
subChild.componentInstance.destroyValue()
}
Expand Down
11 changes: 6 additions & 5 deletions frontend/js/components/Cropper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="cropper">
<header class="cropper__header">
<ul v-if="multiCrops" class="cropper__breakpoints">
<li v-for="(crop, key, index) in cropOptions" :key="key" :class="{ 's--active' : toggleBreakpoint === index }" @click="changeCrop(key, index)">{{ key | capitalize }}</li>
<li v-for="(crop, key, index) in cropOptions" :key="key" :class="{ 's--active' : toggleBreakpoint === index }" @click="changeCrop(key, index)">{{ capitalize(key) }}</li>
</ul>
</header>
<div class="cropper__content">
Expand All @@ -12,7 +12,7 @@
</div>
<footer class="cropper__footer">
<ul v-if="ratiosByContext.length > 1" class="cropper__ratios">
<li class="f--small" v-for="ratio in ratiosByContext" @click="changeRatio(ratio)" :key="ratio.name" :class="{ 's--active' : currentRatioName === ratio.name }">{{ ratio.name | capitalize }}</li>
<li class="f--small" v-for="ratio in ratiosByContext" @click="changeRatio(ratio)" :key="ratio.name" :class="{ 's--active' : currentRatioName === ratio.name }">{{ capitalize(ratio.name) }}</li>
</ul>
<span class="cropper__values f--small hide--xsmall" :class="cropperWarning">{{ cropValues.original.width }} &times; {{ cropValues.original.height }}</span>
<slot></slot>
Expand All @@ -28,7 +28,7 @@

import cropperMixin from '@/mixins/cropper'
import { cropConversion } from '@/utils/cropper'
import a17VueFilters from '@/utils/filters.js'
import { capitalize } from '@/utils/filters.js'

export default {
name: 'a17Cropper',
Expand All @@ -43,6 +43,7 @@
}
},
mixins: [cropperMixin],
emits: ['crop-end'],
data: function () {
return {
cropper: null,
Expand Down Expand Up @@ -109,7 +110,6 @@
allCrops: state => state.mediaLibrary.crops
})
},
filters: a17VueFilters,
mounted: function () {
const opts = this.cropperOpts
const imageBox = this.$refs.cropImage
Expand Down Expand Up @@ -141,6 +141,7 @@
})
},
methods: {
capitalize,
initAspectRatio: function () {
const filtered = this.ratiosByContext
const filter = filtered.find((r) => r.name === this.currentRatioName)
Expand Down Expand Up @@ -217,7 +218,7 @@
return cropConversion(data, this.currentMedia, this.cropValues.natural)
}
},
beforeDestroy: function () {
beforeUnmount: function () {
this.cropper.destroy()
}
}
Expand Down
13 changes: 7 additions & 6 deletions frontend/js/components/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="datePicker__group" :ref="refs.flatPicker">
<div class="form__field datePicker__field">
<input type="text" :name="name" :id="uniqId" :required="required" :placeholder="placeHolder" data-input
@blur="onBlur" v-model="date" :disabled="disabled">
@blur="onBlur" @input="onInput" v-model="date" :disabled="disabled">
<a href="#" v-if="clear" class="datePicker__reset" :class="{ 'datePicker__reset--cleared' : !date }"
@click.prevent="onClear"><span v-svg symbol="close_icon"></span></a>
</div>
Expand All @@ -15,7 +15,7 @@
<script>
import 'flatpickr/dist/flatpickr.css'

import parse from 'date-fns/parse'
import { parse } from 'date-fns'
import FlatPickr from 'flatpickr'

import FormStoreMixin from '@/mixins/formStore'
Expand All @@ -26,6 +26,7 @@
export default {
name: 'A17DatePicker',
mixins: [randKeyMixin, InputframeMixin, FormStoreMixin],
emits: ['input', 'open', 'close', 'blur'],
props: {
/* @see: https://chmln.github.io/flatpickr/options/ */
name: { // FlatPicker hidden input name
Expand Down Expand Up @@ -149,15 +150,15 @@
parseDate: function (date, format) {
const fullFormat = 'yyyy-MM-dd HH:mm:ss';
if (date.length === fullFormat.length) {
return parse(date + 'Z', fullFormat + 'X', Date.UTC());
return parse(date + 'Z', fullFormat + 'X', Date.UTC(0, 0));
}
const fullFormatNoSeconds = 'yyyy-MM-dd HH:mm';
if (date.length === fullFormatNoSeconds.length) {
return parse(date + 'Z', fullFormat + 'X', Date.UTC());
return parse(date + 'Z', fullFormat + 'X', Date.UTC(0, 0));
}
const fullFormatNoTime = 'yyyy-MM-dd';
if (date.length === fullFormatNoTime.length) {
return parse(date, fullFormatNoTime, Date.UTC());
return parse(date, fullFormatNoTime, Date.UTC(0, 0));
}

// Hope for the best..
Expand Down Expand Up @@ -219,7 +220,7 @@

this.isMobile = self.flatPicker.isMobile
},
beforeDestroy: function () {
beforeUnmount: function () {
const self = this
self.flatPicker.destroy()
}
Expand Down