Skip to content

Commit 774736f

Browse files
committed
feat: add UI elements to change nav display
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
1 parent ac42f69 commit 774736f

File tree

4 files changed

+59
-7
lines changed

4 files changed

+59
-7
lines changed

src/modules/modals/CreateContext.vue

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@
3939
</div>
4040
<NcContextResource :resources.sync="resources" :receivers.sync="receivers" />
4141
</div>
42+
<div class="row space-T">
43+
<div>
44+
{{ t('tables', 'Navigation bar entry') }}
45+
</div>
46+
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_HIDDEN"
47+
name="NAV_ENTRY_MODE_HIDDEN" type="radio">
48+
No navigation bar entry
49+
</NcCheckboxRadioSwitch>
50+
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_RECIPIENTS"
51+
name="NAV_ENTRY_MODE_RECIPIENTS" type="radio">
52+
Navigation bar entry for share recipients, but not the owner
53+
</NcCheckboxRadioSwitch>
54+
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_ALL" name="NAV_ENTRY_MODE_ALL"
55+
type="radio">
56+
Navigation bar entry for everybody
57+
</NcCheckboxRadioSwitch>
58+
<br>
59+
</div>
4260
<div class="row space-R row space-T">
4361
<div class="fix-col-4 end">
4462
<NcButton type="primary" :aria-label="t('tables', 'Create application')" data-cy="createContextSubmitBtn" @click="submit">
@@ -51,13 +69,14 @@
5169
</template>
5270

5371
<script>
54-
import { NcModal, NcButton, NcIconSvgWrapper } from '@nextcloud/vue'
72+
import { NcModal, NcButton, NcIconSvgWrapper, NcCheckboxRadioSwitch } from '@nextcloud/vue'
5573
import { showError } from '@nextcloud/dialogs'
5674
import '@nextcloud/dialogs/dist/index.css'
5775
import NcContextResource from '../../shared/components/ncContextResource/NcContextResource.vue'
5876
import NcIconPicker from '../../shared/components/ncIconPicker/NcIconPicker.vue'
5977
import svgHelper from '../../shared/components/ncIconPicker/mixins/svgHelper.js'
6078
import permissionBitmask from '../../shared/components/ncContextResource/mixins/permissionBitmask.js'
79+
import { NAV_ENTRY_MODE } from '../../shared/constants.js'
6180
6281
export default {
6382
name: 'CreateContext',
@@ -67,6 +86,7 @@ export default {
6786
NcButton,
6887
NcIconSvgWrapper,
6988
NcContextResource,
89+
NcCheckboxRadioSwitch,
7090
},
7191
mixins: [svgHelper, permissionBitmask],
7292
props: {
@@ -87,6 +107,7 @@ export default {
87107
description: '',
88108
resources: [],
89109
receivers: [],
110+
displayMode: 'NAV_ENTRY_MODE_HIDDEN',
90111
}
91112
},
92113
watch: {
@@ -147,7 +168,7 @@ export default {
147168
description: this.description,
148169
nodes: dataResources,
149170
}
150-
const res = await this.$store.dispatch('insertNewContext', { data, previousReceivers: [], receivers: this.receivers })
171+
const res = await this.$store.dispatch('insertNewContext', { data, previousReceivers: [], receivers: this.receivers, displayMode: NAV_ENTRY_MODE[this.displayMode] })
151172
if (res) {
152173
return res.id
153174
} else {
@@ -159,6 +180,7 @@ export default {
159180
this.errorTitle = false
160181
this.setIcon(this.randomIcon())
161182
this.customTitleChosen = false
183+
this.displayMode = 'NAV_ENTRY_MODE_HIDDEN'
162184
},
163185
},
164186
}

src/modules/navigation/partials/NavigationContextItem.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@
2929
</template>
3030
{{ t('tables', 'Delete application') }}
3131
</NcActionButton>
32+
<NcActionCheckbox :value="showInNavigation" @change="updateDisplayMode">
33+
Show in Navigation
34+
</NcActionCheckbox>
3235
</template>
3336
</NcAppNavigationItem>
3437
</template>
3538
<script>
36-
import { NcAppNavigationItem, NcActionButton, NcIconSvgWrapper } from '@nextcloud/vue'
39+
import { NcAppNavigationItem, NcActionButton, NcIconSvgWrapper, NcActionCheckbox } from '@nextcloud/vue'
3740
import '@nextcloud/dialogs/dist/index.css'
3841
import { mapGetters } from 'vuex'
3942
import TableIcon from 'vue-material-design-icons/Table.vue'
@@ -43,6 +46,7 @@ import FileSwap from 'vue-material-design-icons/FileSwap.vue'
4346
import Delete from 'vue-material-design-icons/Delete.vue'
4447
import permissionsMixin from '../../../shared/components/ncTable/mixins/permissionsMixin.js'
4548
import svgHelper from '../../../shared/components/ncIconPicker/mixins/svgHelper.js'
49+
import { getCurrentUser } from '@nextcloud/auth'
4650
4751
export default {
4852
name: 'NavigationContextItem',
@@ -55,6 +59,7 @@ export default {
5559
NcIconSvgWrapper,
5660
NcAppNavigationItem,
5761
NcActionButton,
62+
NcActionCheckbox,
5863
},
5964
6065
mixins: [permissionsMixin, svgHelper],
@@ -69,6 +74,7 @@ export default {
6974
data() {
7075
return {
7176
icon: null,
77+
showInNavigation: false,
7278
}
7379
},
7480
computed: {
@@ -95,6 +101,15 @@ export default {
95101
deleteContext() {
96102
emit('tables:context:delete', this.context)
97103
},
104+
updateDisplayMode() {
105+
this.showInNavigation = !this.showInNavigation
106+
if (this.context) {
107+
const share = Object.values(this.context.sharing || {}).find(share => share.receiver === getCurrentUser().uid)
108+
if (share) {
109+
this.$store.dispatch('updateDisplayMode', { shareId: share.share_id, displayMode: this.showInNavigation ? 1 : 0, userId: getCurrentUser().uid })
110+
}
111+
}
112+
},
98113
},
99114
100115
}

src/shared/constants.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ export const TYPE_TEXT = 'text'
4141
export const TYPE_NUMBER = 'number'
4242
export const TYPE_DATETIME = 'datetime'
4343
export const TYPE_USERGROUP = 'usergroup'
44+
45+
export const NAV_ENTRY_MODE = {
46+
NAV_ENTRY_MODE_HIDDEN: 0,
47+
NAV_ENTRY_MODE_RECIPIENTS: 1,
48+
NAV_ENTRY_MODE_ALL: 2,
49+
}

src/store/store.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ export default new Vuex.Store({
342342

343343
return true
344344
},
345-
async shareContext({ dispatch }, { id, previousReceivers, receivers }) {
345+
async shareContext({ dispatch }, { id, previousReceivers, receivers, displayMode }) {
346346
const share = {
347347
nodeType: 'context',
348348
nodeId: id,
349-
displayMode: 2,
349+
displayMode,
350350
}
351351
try {
352352
for (const receiver of receivers) {
@@ -376,15 +376,24 @@ export default new Vuex.Store({
376376
displayError(e, t('tables', 'Could not remove application share.'))
377377
}
378378
},
379-
async insertNewContext({ commit, state, dispatch }, { data, receivers }) {
379+
380+
async updateDisplayMode({ dispatch }, { shareId, displayMode, userId }) {
381+
try {
382+
await axios.put(generateUrl('/apps/tables/share/' + shareId + '/display-mode'), { displayMode, userId })
383+
} catch (e) {
384+
displayError(e, t('tables', 'Could not update display mode.'))
385+
}
386+
},
387+
388+
async insertNewContext({ commit, state, dispatch }, { data, receivers, displayMode }) {
380389
commit('setLoading', { key: 'contexts', value: true })
381390
let res = null
382391

383392
try {
384393
res = await axios.post(generateOcsUrl('/apps/tables/api/2/contexts'), data)
385394
const id = res?.data?.ocs?.data?.id
386395
if (id) {
387-
await dispatch('shareContext', { id, previousReceivers: [], receivers })
396+
await dispatch('shareContext', { id, previousReceivers: [], receivers, displayMode })
388397
}
389398
} catch (e) {
390399
displayError(e, t('tables', 'Could not insert application.'))

0 commit comments

Comments
 (0)