Skip to content

Commit

Permalink
fixup! feat(CalendarOrderModal): add modal for calendar sorting
Browse files Browse the repository at this point in the history
Signed-off-by: Grigory Vodyanov <[email protected]>
  • Loading branch information
GVodyanov committed Nov 30, 2024
1 parent 69ae247 commit 9bf06c7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/components/AppNavigation/CalendarList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</template>

Check warning on line 75 in src/components/AppNavigation/CalendarList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList.vue#L75

Added line #L75 was not covered by tests
<NcModal :show.sync="showOrderModal" @close="showOrderModal = false">
<CalendarOrderModal />
<CalendarOrderModal :passed-calendars="calendars" />

Check warning on line 77 in src/components/AppNavigation/CalendarList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList.vue#L77

Added line #L77 was not covered by tests
</NcModal>
</div>

Check warning on line 79 in src/components/AppNavigation/CalendarList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList.vue#L79

Added line #L79 was not covered by tests
</template>
Expand Down
53 changes: 29 additions & 24 deletions src/components/AppNavigation/CalendarList/CalendarOrderModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import draggable from 'vuedraggable'
import debounce from 'debounce'

Check warning on line 50 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L50

Added line #L50 was not covered by tests
import { showError } from '@nextcloud/dialogs'
import pLimit from 'p-limit'
import { mapStores, mapState } from 'pinia'
import { mapStores } from 'pinia'
import useCalendarsStore from '../../../store/calendars.js'

const limit = pLimit(1)
Expand All @@ -63,41 +63,44 @@ export default {
NcAppNavigationCaption,
},

Check warning on line 64 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L62-L64

Added lines #L62 - L64 were not covered by tests
props: {

passedCalendars: {
type: Array,
required: true,

Check warning on line 68 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L68

Added line #L68 was not covered by tests
},
},

Check warning on line 70 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L70

Added line #L70 was not covered by tests
data() {
return {

Check warning on line 72 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L72

Added line #L72 was not covered by tests
disableDragging: false,
sortedCalendars: {
personal: [],
shared: [],
deck: [],
hidden: [],
},
sortedCalendars: {},
}
},
computed: {
...mapStores(useCalendarsStore),
...mapState(useCalendarsStore, {
serverCalendars: 'sortedCalendarsSubscriptions',
calendars: 'calendars',
}),
},
mounted() {
this.calendars.forEach((calendar) => {
console.log(calendar)
if (calendar.isSharedWithMe) {
this.sortedCalendars.shared.push(calendar)
return
watch: {
passedCalendars(newVal) {

Check warning on line 81 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L78-L81

Added lines #L78 - L81 were not covered by tests
this.calendars = newVal
this.sortedCalendars = {
personal: [],
shared: [],

Check warning on line 85 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L85

Added line #L85 was not covered by tests
deck: [],
hidden: [],
}

Check warning on line 88 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L88

Added line #L88 was not covered by tests

if (calendar.url.includes('app-generated--deck--board')) {
this.sortedCalendars.deck.push(calendar)
return
}
this.calendars.forEach((calendar) => {
if (calendar.isSharedWithMe) {
this.sortedCalendars.shared.push(calendar)
return
}

if (calendar.url.includes('app-generated--deck--board')) {
this.sortedCalendars.deck.push(calendar)
return
}

this.sortedCalendars.personal.push(calendar)
})
this.sortedCalendars.personal.push(calendar)
})

Check warning on line 102 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L101-L102

Added lines #L101 - L102 were not covered by tests
},
},
methods: {
update: debounce(async function() {
Expand All @@ -112,6 +115,8 @@ export default {
return newOrderObj
}, {})

Check warning on line 117 in src/components/AppNavigation/CalendarList/CalendarOrderModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/CalendarList/CalendarOrderModal.vue#L116-L117

Added lines #L116 - L117 were not covered by tests
this.calendars = currentCalendars

try {
await limit(() => this.calendarsStore.updateCalendarListOrder({ newOrder }))
} catch (err) {
Expand Down

0 comments on commit 9bf06c7

Please sign in to comment.