From fc6cc1354c6133aa45c43b2217faabb0fece025a Mon Sep 17 00:00:00 2001 From: tobiaschielens Date: Tue, 15 Oct 2019 10:16:35 +0200 Subject: [PATCH 1/3] Starting to make calendar dynamic --- public/config/config.local | 2 +- src/components/fullevent/fullevent.html | 148 +++++++++++++++++++++ src/components/fullevent/fullevent.js | 140 +++++++++++++++++++ src/components/fullevent/fullevent.scss | 4 + src/components/fullevent/fullevent.spec.js | 29 ++++ src/components/fullevent/index.vue | 3 + src/views/calendar/calendar.html | 8 ++ src/views/calendar/calendar.js | 17 ++- 8 files changed, 343 insertions(+), 8 deletions(-) create mode 100644 src/components/fullevent/fullevent.html create mode 100644 src/components/fullevent/fullevent.js create mode 100644 src/components/fullevent/fullevent.scss create mode 100644 src/components/fullevent/fullevent.spec.js create mode 100644 src/components/fullevent/index.vue diff --git a/public/config/config.local b/public/config/config.local index 028a5264..d36e1e4d 100644 --- a/public/config/config.local +++ b/public/config/config.local @@ -1,6 +1,6 @@ export default ({ tfApiUrl: 'https://radar.threefold.io/api/', - jsApiUrl: `http://172.17.0.2/api/actors/`, + jsApiUrl: `https://172.17.0.2/web/gedis/http/`, apiUrl: 'https://ffc-signaling.staging.jimber.org', janus: 'http://ffc-video.jimber.staging.org/janus', diff --git a/src/components/fullevent/fullevent.html b/src/components/fullevent/fullevent.html new file mode 100644 index 00000000..a16ada7f --- /dev/null +++ b/src/components/fullevent/fullevent.html @@ -0,0 +1,148 @@ +
+ + + +
+ + + fas fa-save + + + fas fa-times + + + fas fa-star + far fa-star + + + fas fa-pencil-alt + + + + + + + fas fa-trash + + Delete contact + + + + +
+ + + + + + + + + +

+ Event details +

+ + + + + +
+ Cancel + OK +
+
+
+ + + + +
+ Cancel + OK +
+
+
+
+ + + + + +
+ Cancel + OK +
+
+
+ + + + +
+ Cancel + OK +
+
+
+
+ + + +
+
+
+
\ No newline at end of file diff --git a/src/components/fullevent/fullevent.js b/src/components/fullevent/fullevent.js new file mode 100644 index 00000000..e664eaf9 --- /dev/null +++ b/src/components/fullevent/fullevent.js @@ -0,0 +1,140 @@ +import { mapActions } from 'vuex' +import config from '../../../public/config' +import cloneDeep from 'lodash.clonedeep' + +export default { + name: 'fullevent', + components: {}, + props: { + editable: { + type: Boolean, + default: false + }, + contact: { + type: Object, + default: () => { + return { + addresses: [{}], + email: [{}], + phone_numbers: [{}] + } + } + } + }, + data () { + return { + description: config.description, + edit: this.editable, + currentEvent: { + + }, + startDateDialog: false + } + }, + computed: { + currentSalutations: { + get () { + return this.currentEvent.salutation ? this.currentEvent.salutation.split(',') : [] + }, + set (val) { + this.currentEvent.salutation = val.join(',') + } + } + }, + mounted () { + this.currentEvent = cloneDeep(this.contact) + this.edit = cloneDeep(this.editable) + }, + methods: { + ...mapActions([ + 'deleteContact', + 'createContact' + ]), + updateFavorite (isFavorite) { + this.currentEvent.favorite = isFavorite + this.createContact(this.currentEvent) + }, + openFilePicker () { + this.$refs.image.click() + }, + onFilePicked (e) { + const files = e.target.files + if (e.target.files && e.target.files[0]) { + var fr = new window.FileReader() + fr.addEventListener('load', (x) => { + this.currentEvent.picture = x.target.result + }) + fr.readAsDataURL(files[0]) + } + }, + updateContact () { + if (this.$refs.contactForm.validate()) { + for (let index = 0; index < this.currentEvent.email.length; index++) { + const element = this.currentEvent.email[index] + if (!element.email) { + this.currentEvent.email.splice(index, 1) + } + } + for (let index = 0; index < this.currentEvent.phone_numbers.length; index++) { + const element = this.currentEvent.phone_numbers[index] + if (!element.number) { + this.currentEvent.phone_numbers.splice(index, 1) + } + } + for (let index = 0; index < this.currentEvent.addresses.length; index++) { + const element = this.currentEvent.addresses[index] + if (!element.street_name) { + this.currentEvent.addresses.splice(index, 1) + } + } + this.createContact(this.currentEvent) + this.edit = false + this.$emit('update') + } + }, + cancelUpdate () { + this.currentEvent = cloneDeep(this.contact) + this.edit = false + this.$refs.contactForm.resetValidation() + this.$emit('cancel') + }, + addPhoneNumber () { + this.currentEvent.phone_numbers.push({}) + }, + removeNumber (index) { + // TODO show dialog "are you sure" + this.currentEvent.phone_numbers.splice(index, 1) + }, + addAddress () { + this.currentEvent.addresses.push({}) + }, + removeAddress (index) { + // TODO show dialog "are you sure" + this.currentEvent.addresses.splice(index, 1) + }, + addEmail () { + this.currentEvent.email.push({}) + }, + removeEmail (index) { + // TODO show dialog "are you sure" + this.currentEvent.email.splice(index, 1) + }, + deleteThisContact () { + // TODO show dialog "are you sure" + this.deleteContact(this.currentEvent.id) + this.$emit('delete:contact', this.currentEvent.id) + } + }, + watch: { + edit: { + immediate: true, + handler (val) { + if (val) { + if (!this.currentEvent.phone_numbers.length) this.currentEvent.phone_numbers.push({}) + if (!this.currentEvent.email.length) this.currentEvent.email.push({}) + if (!this.currentEvent.addresses.length) this.currentEvent.addresses.push({}) + } + } + } + } +} diff --git a/src/components/fullevent/fullevent.scss b/src/components/fullevent/fullevent.scss new file mode 100644 index 00000000..d0408c0a --- /dev/null +++ b/src/components/fullevent/fullevent.scss @@ -0,0 +1,4 @@ +.fullcontact { + height: 100%; + width: 100%; +} \ No newline at end of file diff --git a/src/components/fullevent/fullevent.spec.js b/src/components/fullevent/fullevent.spec.js new file mode 100644 index 00000000..6712d5bd --- /dev/null +++ b/src/components/fullevent/fullevent.spec.js @@ -0,0 +1,29 @@ +import Vue from 'vue'; +import FullcontactComponent from './index.vue'; + +// Here are some Jasmine 2.0 tests, though you can +// use any test runner / assertion library combo you prefer +describe('FullcontactComponent', () => { + // Inspect the raw component options + it('has a created hook', () => { + // expect(typeof FullcontactComponent.created).toBe('function'); + }) + // Evaluate the results of functions in + // the raw component options + it('sets the correct default data', () => { + // expect(typeof FullcontactComponent.data).toBe('function') + // const defaultData = FullcontactComponent.data(); + // expect(defaultData.message).toBe('hello!'); + }) + // Inspect the component instance on mount + it('correctly sets the message when created', () => { + // const vm = new Vue(FullcontactComponent).$mount(); + // expect(vm.message).toBe('bye!'); + }) + // Mount an instance and inspect the render output + it('renders the correct message', () => { + // const Ctor = Vue.extend(FullcontactComponent); + // const vm = new Ctor().$mount(); + // expect(vm.$el.textContent).toBe('bye!'); + }) +}) \ No newline at end of file diff --git a/src/components/fullevent/index.vue b/src/components/fullevent/index.vue new file mode 100644 index 00000000..54d23f54 --- /dev/null +++ b/src/components/fullevent/index.vue @@ -0,0 +1,3 @@ + + + diff --git a/src/views/calendar/calendar.html b/src/views/calendar/calendar.html index 31a0dfea..5e904546 100644 --- a/src/views/calendar/calendar.html +++ b/src/views/calendar/calendar.html @@ -24,4 +24,12 @@ + + + + + + + fas fa-plus + \ No newline at end of file diff --git a/src/views/calendar/calendar.js b/src/views/calendar/calendar.js index 882afdfd..76d4dfe1 100644 --- a/src/views/calendar/calendar.js +++ b/src/views/calendar/calendar.js @@ -1,10 +1,14 @@ +import fullEvent from '../../components/fullevent' + export default { name: 'calendar', - components: {}, + components: { fullEvent }, props: [], data () { return { today: '2019-01-08', + openEvent: {}, + addEventDialog: false, events: [ { name: 'Weekly Meeting', @@ -19,11 +23,7 @@ export default { name: 'Mash Potatoes', start: '2019-01-09 12:30', end: '2019-01-09 15:30' - }, -// { -// name: '', -// start: '2019-01-10' -// } + } ] } }, @@ -34,6 +34,9 @@ export default { this.$refs.calendar.scrollToTime('08:00') }, methods: { - + clearAndClose () { + this.newEvent = {} + this.addEventDialog = false + } } } From 164ec77f58aa06474c6dd4fe1a4ef9b018177b55 Mon Sep 17 00:00:00 2001 From: tobiaschielens Date: Thu, 17 Oct 2019 10:29:08 +0200 Subject: [PATCH 2/3] Add event works --- .../calendarnavigation.html | 29 ++++ .../calendarnavigation/calendarnavigation.js | 32 +++++ .../calendarnavigation.scss | 3 + .../calendarnavigation.spec.js | 29 ++++ src/components/calendarnavigation/index.vue | 3 + src/components/fullevent/fullevent.html | 132 ++++++++---------- src/components/fullevent/fullevent.js | 124 ++-------------- src/services/calendarService.js | 51 +++++++ src/store/calendarStore.js | 67 +++++++++ src/store/index.js | 4 +- src/views/calendar/calendar.html | 23 +-- src/views/calendar/calendar.js | 43 +++--- 12 files changed, 323 insertions(+), 217 deletions(-) create mode 100644 src/components/calendarnavigation/calendarnavigation.html create mode 100644 src/components/calendarnavigation/calendarnavigation.js create mode 100644 src/components/calendarnavigation/calendarnavigation.scss create mode 100644 src/components/calendarnavigation/calendarnavigation.spec.js create mode 100644 src/components/calendarnavigation/index.vue create mode 100644 src/services/calendarService.js create mode 100644 src/store/calendarStore.js diff --git a/src/components/calendarnavigation/calendarnavigation.html b/src/components/calendarnavigation/calendarnavigation.html new file mode 100644 index 00000000..95153c15 --- /dev/null +++ b/src/components/calendarnavigation/calendarnavigation.html @@ -0,0 +1,29 @@ +
+ + + + + + fad fa-calendar-alt + + + {{calendar.name}} + + + + + + + + + + + + + + add + + + + +
\ No newline at end of file diff --git a/src/components/calendarnavigation/calendarnavigation.js b/src/components/calendarnavigation/calendarnavigation.js new file mode 100644 index 00000000..8b9305a7 --- /dev/null +++ b/src/components/calendarnavigation/calendarnavigation.js @@ -0,0 +1,32 @@ +import { mapActions, mapGetters } from 'vuex' + +export default { + name: 'calendarnavigation', + components: {}, + props: [], + data () { + return { + selectedBox: 0, + newCalendar: '' + } + }, + computed: { + ...mapGetters([ + 'calendars' + ]) + }, + mounted () { + }, + methods: { + ...mapActions([ + 'addCalendar' + ]), + addCal () { + this.addCalendar(this.newCalendar) + this.newCalendar = '' + }, + setSelectedCalendar (calendarId) { + this.$emit('setSelectedCalendar', calendarId) + } + } +} diff --git a/src/components/calendarnavigation/calendarnavigation.scss b/src/components/calendarnavigation/calendarnavigation.scss new file mode 100644 index 00000000..2d41c541 --- /dev/null +++ b/src/components/calendarnavigation/calendarnavigation.scss @@ -0,0 +1,3 @@ +.emailnavigation { + +} diff --git a/src/components/calendarnavigation/calendarnavigation.spec.js b/src/components/calendarnavigation/calendarnavigation.spec.js new file mode 100644 index 00000000..a8f716b7 --- /dev/null +++ b/src/components/calendarnavigation/calendarnavigation.spec.js @@ -0,0 +1,29 @@ +import Vue from 'vue'; +import EmailnavigationComponent from './index.vue'; + +// Here are some Jasmine 2.0 tests, though you can +// use any test runner / assertion library combo you prefer +describe('EmailnavigationComponent', () => { + // Inspect the raw component options + it('has a created hook', () => { + // expect(typeof EmailnavigationComponent.created).toBe('function'); + }) + // Evaluate the results of functions in + // the raw component options + it('sets the correct default data', () => { + // expect(typeof EmailnavigationComponent.data).toBe('function') + // const defaultData = EmailnavigationComponent.data(); + // expect(defaultData.message).toBe('hello!'); + }) + // Inspect the component instance on mount + it('correctly sets the message when created', () => { + // const vm = new Vue(EmailnavigationComponent).$mount(); + // expect(vm.message).toBe('bye!'); + }) + // Mount an instance and inspect the render output + it('renders the correct message', () => { + // const Ctor = Vue.extend(EmailnavigationComponent); + // const vm = new Ctor().$mount(); + // expect(vm.$el.textContent).toBe('bye!'); + }) +}) \ No newline at end of file diff --git a/src/components/calendarnavigation/index.vue b/src/components/calendarnavigation/index.vue new file mode 100644 index 00000000..e68fde3a --- /dev/null +++ b/src/components/calendarnavigation/index.vue @@ -0,0 +1,3 @@ + + + diff --git a/src/components/fullevent/fullevent.html b/src/components/fullevent/fullevent.html index a16ada7f..9238c689 100644 --- a/src/components/fullevent/fullevent.html +++ b/src/components/fullevent/fullevent.html @@ -1,19 +1,11 @@
- - +
- + fas fa-save - - fas fa-times - - - fas fa-star - far fa-star - fas fa-pencil-alt @@ -24,14 +16,17 @@ - + fas fa-trash - Delete contact + Delete event + + fas fa-times +
@@ -43,6 +38,24 @@ + +

+ Select calendar +

+ + + + + +

Event details @@ -56,7 +69,7 @@

prepend-icon="fas fa-calendar" readonly v-on="on"> - +
Cancel OK @@ -64,8 +77,8 @@

- +