Vue.js and FullCalendar 5 refetchEvents - ajax

I am using FullCalendar and Vue.
I am trying to reload the events once the refreshCal() is triggered and so render the calendar on the screen with refetchEvents.
I have to main components:
The Calendar: here is the code
<script>
import FullCalendar from '#fullcalendar/vue'
import timeGridPlugin from '#fullcalendar/timegrid'
import resourceTimelinePlugin from '#fullcalendar/resource-timeline'
import calendarEdit from '../pages/calendar/edit'
export default {
components: {
FullCalendar
},
data() {
return {
calendarOptions: {
plugins: [ timeGridPlugin, resourceTimelinePlugin ],
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
initialView: 'timeGridWeek',
refetchResourcesOnNavigate: true,
//eventSources: ['/api/calendar/json'],
events: '/api/calendar/json',
eventDisplay: 'block',
contentHeight: 'auto',
nowIndicator: true,
locale: 'en-gb',
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'timeGridWeek, timeGridDay'
},
businessHours: [ // specify an array instead
{
daysOfWeek: [ 1, 2, 3, 4, 5 ], // Monday, Tuesday, Wednesday
startTime: '08:00', // 8am
endTime: '20:00' // 6pm
},
{
daysOfWeek: [ 6 ], // Thursday, Friday
startTime: '9:00', // 10am
endTime: '14:00' // 4pm
}
],
slotMinTime: '07:00:00',
slotMaxTime: '24:00:00',
expandRows: true,
eventClick: this.eventModal,
}
}
},
methods: {
eventModal(args) {
let modalProps = {
'event': args.event
}
this.$buefy.modal.open({
props: modalProps,
parent: this,
component: calendarEdit,
hasModalCard: true,
trapFocus: true
})
}
}
}
</script>
<template>
<FullCalendar ref="calsession" :options="calendarOptions"/>
</template>
A modal component to edit the event:
<script>
export default {
data() {
return {
session: {},
startDate: {},
startTime: {},
endTime: {},
message: {}
}
},
props: {
event: {
required: true
}
},
methods: {
getSession() {
this.$http.get(`/api/sessions/${this.event.id}/edit`)
.then( (result) => {
this.session = result.data;
this.startDate = new Date(result.data.start_at)
this.startTime = new Date(result.data.start_at)
this.endTime = new Date(result.data.finish_at)
})
},
update(event) {
this.saving = true;
this.$http.put(`/api/sessions/${this.event.id}`, {
startDate: this.$moment(this.startDate).utc().format('YYYY-MM-DD'),
startTime: this.$moment(this.startTime).utc().format('hh:mm'),
endTime: this.$moment(this.endTime).utc().format('hh:mm')
}).then((response) => {
this.refreshCal()
//this.close()
})
},
refreshCal() {
this.$log(this.$parent.$parent.$refs)
this.$parent.$parent.$refs.calsession.refetchEvents()
}
},
created() {
this.getSession()
}
}
</script>
I have been trying
this.$parent.$parent.$refs.calsession.$emit('refetch-events')
as found in FullCalendar documents and various researches on the internet but it has never worked.
$emit('refetch-events') or $emit('refetchEvents') doens't do anything.
Just for information: this.$parent.$parent.$refs gives the refs to FullCalendar.
Any suggestion?
Thank you all for any kind of help.

if using the official Vue component for Fullcalendar: #fullcalendar/vue
don't need to use emit but get the Calendar object through the getApi method:
let calendar = this.$parent.$parent.$refs.calsession.getApi()
and so using the method refetchEvents:
calendar.refetchEvents()

Related

React-slick with gatsby-plugin-image

I'm trying to use React-slick with gatsby-plugin images and I have the page setup like this.
import React from "react";
import { graphql } from "gatsby"
import Slider from "react-slick";
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";
import { GatsbyImage } from "gatsby-plugin-image"
const settings = {
autoPlay: true,
arrows: false,
dots: true,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1,
};
const ImgSlide = ({ data }) => {
return (
<div>
<Slider {...settings}>
<div>
<GatsbyImage fluid={data.image1.childImageSharp.fluid} />
</div>
<div>
<GatsbyImage fluid={data.image2.childImageSharp.fluid} />
</div>
</Slider>
</div>
);
};
export const pageQuery = graphql`
query {
image1: file(relativePath: { eq: "images/icon.png" }) {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
image2: file(relativePath: { eq: "images/icon.png" }) {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
}
`
export default ImgSlide;
When i run Gatsby develop I get an error saying image1 is not defined. I really don't know what I'm missing here. I think it has something to do with how I'm trying to define image1 but I'm pretty sure I've used relativePath properly unless I'm not specifying the location properly.
I do have the same image specified twice that is just because I have not imported the photos in just yet I'm just testing to make it work.
gatsby-config setup is
module.exports = {
siteMetadata: {
title: "Inkd Era",
description: "Clothing and brand built for tattoo and tattoed culture",
},
plugins: [
"gatsby-plugin-sass",
"gatsby-plugin-image",
"gatsby-plugin-react-helmet",
"gatsby-plugin-sitemap",
{
resolve: "gatsby-plugin-manifest",
options: {
icon: "src/images/icon.png",
},
},
"gatsby-transformer-remark",
"gatsby-plugin-sharp",
"gatsby-transformer-sharp",
{
resolve: "gatsby-transformer-remark",
options: {
plugins: [
{
resolve: "gatsby-remark-images",
options: {
maxWidth: 650,
},
},
],
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "images",
path: `${__dirname}/src/images/`,
},
__key: "images",
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "pages",
path: `${__dirname}/src/pages/`,
},
__key: "pages",
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `Inkd Era`,
short_name: `Inkd era`,
start_url: `/`,
background_color: `#000`,
theme_color: `#fafafa`,
display: `standalone`,
icon: `content/assets/gatsby-icon.png`,
},
},
],
};
The structure for the new <GatsbyImage> component when passing the image itself is using the image prop, not fluid. In addition, the query needs to fetch gatsbyImageData, not fluid as you can see in the docs:
import { graphql } from "gatsby"
import { GatsbyImage, getImage } from "gatsby-plugin-image"
function BlogPost({ data }) {
const image = getImage(data.blogPost.avatar)
return (
<section>
<h2>{data.blogPost.title}</h2>
<GatsbyImage image={image} alt={data.blogPost.author} />
<p>{data.blogPost.body}</p>
</section>
)
}
export const pageQuery = graphql`
query {
blogPost(id: { eq: $Id }) {
title
body
author
avatar {
childImageSharp {
gatsbyImageData(
width: 200
placeholder: BLURRED
formats: [AUTO, WEBP, AVIF]
)
}
}
}
}
`
In your scenario, you are mixing the gatsby-image approach, from Gatsby v2 with the new gatsby-plugin-image, which stills in beta, but it's from the v3.
If you want to use the <GatsbyImage>, adapt the query and the component to the needs, otherwise, use the gatsby-image properly like:
import Img from `gatsby-image`
<Img fluid={data.image1.childImageSharp.fluid} />

Fullcalendar does not display the events

I cannot display the events in the fullcalendar, I am using vue and vuex to develop a laravel nova compoment with a modal window, I already try in some many ways but without success. I hope anyone can help me.
my store is this:
import Vuex from 'vuex';
Nova.booting((Vue, router, store) => {
Vue.component('fullcalendar', require('./components/Tool'))
Vue.use(Vuex);
Nova.store = new Vuex.Store({
state: {
event: [],
events: [],
},
mutations: {
SET_EVENT(state, event) {
state.event = event;
},
ADD_TO_EVENTS(state, event) {
state.events.push(event);
}
},
actions: {
setEvent(context, event) {
context.commit('SET_EVENT', event);
},
addToEvents(context, event) {
context.commit('ADD_TO_EVENTS', event);
},
},
getters: {
event: state => state.event,
events: state => state.events,
},
});
})
my Tool.vue is this
<template>
<div>
event {{ events }}
<FullCalendar ref="fullcalendar" :options="calendarOptions"/>
<modal :show="showModal" #close="showModal = false"></modal>
<button id="show-modal" #click="showModal = true"></button>
</div>
</template>
<script>
import FullCalendar from '#fullcalendar/vue';
import dayGridPlugin from '#fullcalendar/daygrid';
import timeGridPlugin from '#fullcalendar/timegrid';
import listGridPlugin from '#fullcalendar/list';
import interactionPlugin from '#fullcalendar/interaction';
import modal from './Modal.vue';
export default {
props: ['resourceName', 'resourceId', 'panel'],
components: {
modal,
FullCalendar, // make the <FullCalendar> tag available
},
data() {
return {
showModal: false,
calendarOptions: {
plugins: [ dayGridPlugin, timeGridPlugin, listGridPlugin, interactionPlugin ],
initialView: 'dayGridMonth',
events: this.events,
editable: true,
select: this.handleDateClick,
eventClick: this.handleEventClick,
buttonText: {
today: 'Today',
month: 'Month',
week: 'Week',
day: 'Day',
list: 'Agenda'
},
headerToolbar : {
end: 'prevYear,prev today next,nextYear',
center: 'title',
start: 'dayGridMonth,timeGridWeek,timeGridDay listMonth',
},
stickyHeaderDates: true,
aspectRatio: 2.4,
navLinks: true,
selectable: true,
nowIndicator: true,
dayMaxEventRows: true,
dayMaxEvents: 10,
moreLinkClick: 'popover',
businessHours: {
daysOfWeek: [ 1, 2, 3, 4, 5 ], // Monday - Thursday
startTime: '8:00',
endTime: '18:00',
}
}
}
},
mounted() {
this.showModal = false;
},
computed: {
events: () => {
return Nova.store.getters.events;
},
},
methods: {
handleDateClick(arg) {
const event = {
title:'something',
start: moment(arg.start).format('YYYY-MM-DD'),
end: moment(arg.end).format('YYYY-MM-DD'),
allDay: true,
};
Nova.store.dispatch('setEvent', event);
this.showModal = true;
},
handleEventClick(event) {
this.showModal = true;
},
},
}
</script>
my modal window file is this
<template>
<div>
event {{ events }}
<FullCalendar ref="fullcalendar" :options="calendarOptions"/>
<modal :show="showModal" #close="showModal = false"></modal>
<button id="show-modal" #click="showModal = true"></button>
</div>
</template>
<script>
import FullCalendar from '#fullcalendar/vue';
import dayGridPlugin from '#fullcalendar/daygrid';
import timeGridPlugin from '#fullcalendar/timegrid';
import listGridPlugin from '#fullcalendar/list';
import interactionPlugin from '#fullcalendar/interaction';
import modal from './Modal.vue';
export default {
props: ['resourceName', 'resourceId', 'panel'],
components: {
modal,
FullCalendar, // make the <FullCalendar> tag available
},
data() {
return {
showModal: false,
calendarOptions: {
plugins: [ dayGridPlugin, timeGridPlugin, listGridPlugin, interactionPlugin ],
initialView: 'dayGridMonth',
events: this.events,
editable: true,
select: this.handleDateClick,
eventClick: this.handleEventClick,
buttonText: {
today: 'Today',
month: 'Month',
week: 'Week',
day: 'Day',
list: 'Agenda'
},
headerToolbar : {
end: 'prevYear,prev today next,nextYear',
center: 'title',
start: 'dayGridMonth,timeGridWeek,timeGridDay listMonth',
},
stickyHeaderDates: true,
aspectRatio: 2.4,
navLinks: true,
selectable: true,
nowIndicator: true,
dayMaxEventRows: true,
dayMaxEvents: 10,
moreLinkClick: 'popover',
businessHours: {
daysOfWeek: [ 1, 2, 3, 4, 5 ], // Monday - Thursday
startTime: '8:00',
endTime: '18:00',
}
}
}
},
mounted() {
this.showModal = false;
},
computed: {
events: () => {
return Nova.store.getters.events;
},
},
methods: {
handleDateClick(arg) {
const event = {
title:'something',
start: moment(arg.start).format('YYYY-MM-DD'),
end: moment(arg.end).format('YYYY-MM-DD'),
allDay: true,
};
Nova.store.dispatch('setEvent', event);
this.showModal = true;
},
handleEventClick(event) {
this.showModal = true;
},
},
}
</script>
Do you have any clue why I can see the event in the calendar?
I appreciate any help
Thks,
I had the same problem.
I put the calendaroptions in computed
you can check this repository (Vue-vuex)
https://github.com/fullcalendar/fullcalendar-example-projects

facing problem in vue apexchart dynamic data set from api

I am try to create vue barchart & using apexChartData.
Here is my code
export default{
components: {
VueApexCharts
},
data () {
return {
barChart: {
series: [{
data: []
}],
chartOptions: {
plotOptions: {
bar: {
horizontal: true
}
},
dataLabels: {
enabled: false
},
xaxis: {
categories: []
}
}
}
},
methods: {
myFunction() {
this.$vs.loading();
axios.get("/api/auth/nameofapi").then(response => {
this.barChart.series[0].data = response.data[0]['data'];
this.barChart.chartOptions.xaxis.categories = response.data[1]['categories'];
this.$vs.loading.close();
}).catch(error => {
this.$vs.loading.close()
this.errorResponse(error);
});
}
},
mounted () {
this.myFunction();
}
}
My API Response payload like
[{"data":[4,1]},{"categories":["xyz","abc"]}]
After doing this bar chart is not loading, i am not sure where i am doing mistake, sorry for repeating this post if already exist but i just post what i am facing.
Any Help
Thanks in advance

How to implement Quill Emojis in vue2editor?

I tried to add Quill Emojis to editor but I am getting console error as
Uncaught ReferenceError: Quill is not defined
I am using Laravel 5.6 and vue js and definately new to vue and its components so I may sound silly to you but for the past 3 days I am searching on the google for the solution and even contacted author of vue2editor on github here is the link
This is what I have tried so far:
vue2editor.vue
<template>
<div id="app">
<vue-editor v-model="content"></vue-editor>
</div>
</template>
<script>
import { VueEditor, Quill } from 'vue2-editor';
import Emoji from 'quill-emoji/dist/quill-emoji';
Quill.register('modules/quill-emoji', Emoji);
export default {
name: 'vue2editor',
components: { VueEditor },
data() {
return {
content: "<h1>Some initial content</h1>",
editorSettings: {
modules: {
toolbar: {
container: [
[{'size': ['small', false, 'large']}],
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }],
[{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }],
[{ 'align': [] }],
['clean'],
['link', 'image', 'video'],
['emoji'],
],
handlers: {
'emoji': function () {}
},
},
toolbar_emoji: true,
short_name_emoji: true,
textarea_emoji:true,
},
},
text: null,
};
},
};
</script>
I even tried the method mentioned by one of the user on github for Quill-Emoji, here is the link.
I came here with lots of hopes; if anyone here is to help me out, at least tell me what I am missing will be more than a help for me.
Quill.register({
'formats/emoji': Emoji.EmojiBlot,
'modules/short_name_emoji': Emoji.ShortNameEmoji,
'modules/toolbar_emoji': Emoji.ToolbarEmoji,
'modules/textarea_emoji': Emoji.TextAreaEmoji}, true);
you need register the model, add the up code to you code.
Edit:
//1) Add plugin to laravel mix
const mix = require('laravel-mix')
mix.webpackConfig(webpack => {
return {
plugins: [
new webpack.ProvidePlugin({
"window.Quill": "quill/dist/quill.js",
Quill: "quill/dist/quill.js"
})
]
};
});
//2 example vue file
<template>
<div class="mt-1">
<vue-editor
ref="editor"
v-model="content"
:editor-toolbar="customToolbar"
:editorOptions="editorSettings"
/>
</div>
</template>
<script>
import { VueEditor, Quill } from "vue2-editor";
import Emoji from "quill-emoji/dist/quill-emoji";
Quill.register("modules/emoji", Emoji);
export default {
components: {
VueEditor,
},
props: {
bubble: Object,
contentCol: {
type: String,
},
},
data() {
return {
edit: false,
content: "<b>Content is here</b>",
customToolbar: [["bold", "italic", "underline"], ["link"], ["emoji"]],
editorSettings: {
modules: {
"emoji-toolbar": true,
"emoji-textarea": true,
"emoji-shortname": true,
},
},
};
},
beforeDestroy() {},
};
</script>
<style src="quill-emoji/dist/quill-emoji.css"/>

eventlisters not working in controller

I'm working on my very first Sencha Touch 2 project, so I'm not very familiar with it yet. I'm using the Sencha documentation and have been Googling and Stackoverflowing a lot, but can't seem to find the answer to this problem.
I'm working in MVC and want to add some eventlisteners (in the controller) to controls in my view. Whatever I try, they don't seem to work, although they work when I add them in the view itself. Ofcourse that's not best practice at all, so I'm wondering what I'm doing wrong?
This is how my controller looks:
Ext.define("workingTime.controller.MainController", {
extend: "Ext.app.Controller",
views: ['Main'],
refs: [
{
sl_break: '#sl_break'
},
{
sl_work: '#sl_work'
}
],
init: function() {
this.control({
'sl_break': {
change: 'setBreakTime'
}
});
},
setBreakTime: function(newValue) {
console.log('set');
}
});
And this is how my view looks (with the listener still added):
Ext.define("workingTime.view.Main", {
extend: 'Ext.form.Panel',
controllers: ['MainController'],
requires: [
'Ext.field.Slider'
],
config: {
fullscreen: true,
items: [
{
xtype: 'label',
html: '<p class="label_field">Take a <span>five</span> minute break<p>'
},
{
xtype: 'sliderfield',
name: 'sl_break',
value: 5,
minValue: 1,
maxValue: 30,
style: {
'background-color' : '#FFecc0'
},
listeners: {
change: function() {
alert('changed');
}
}
},
{
]
}
});
Tell me if you need more info.
I would try: (without init function)
config: {
refs: {
sl_break: '#sl_break',
sl_work: '#sl_work'
},
control: {
sl_break: {
change: 'setBreakTime'
}
}
},
in your controller add sl_break: 'main sliderfield[itemId=sl_break]' in refs
Ext.define("workingTime.controller.MainController", {
extend: "Ext.app.Controller",
views: ['Main'],
refs: [
{
sl_break: 'main sliderfield[itemId=sl_break]'
}
],
init: function() {
this.control({
'sl_break': {
change: 'setBreakTime'
}
});
},
setBreakTime: function(newValue) {
console.log('set');
}
});
in view add alias to main and itemId to sliderfield
Ext.define("workingTime.view.Main", {
extend: 'Ext.form.Panel',
controllers: ['MainController'],
alias: 'widget.main',
requires: [
'Ext.field.Slider'
],
config: {
fullscreen: true,
items: [
{
xtype: 'label',
html: '<p class="label_field">Take a <span>five</span> minute break<p>'
},
{
xtype: 'sliderfield',
name: 'sl_break',
itemId:'sl_break',
value: 5,
minValue: 1,
maxValue: 30,
style: {
'background-color' : '#FFecc0'
},
listeners: {
change: function() {
alert('changed');
}
}
},
{
]
}
});
i hope it will work

Resources