Skip to content

Commit ef29cf6

Browse files
committed
enh: use checkbox for default nav display mode
Signed-off-by: Cleopatra Enjeck M <[email protected]>
1 parent c73d7f1 commit ef29cf6

File tree

4 files changed

+55
-48
lines changed

4 files changed

+55
-48
lines changed

src/modules/modals/CreateContext.vue

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,12 @@
4343
<NcContextResource :resources.sync="resources" :receivers.sync="receivers" />
4444
</div>
4545
<div class="row space-T">
46-
<div>
47-
{{ t('tables', 'Navigation bar display') }}
48-
</div>
49-
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_HIDDEN"
50-
name="NAV_ENTRY_MODE_HIDDEN" type="radio">
51-
Hide navigation entry for everybody
52-
</NcCheckboxRadioSwitch>
53-
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_RECIPIENTS"
54-
name="NAV_ENTRY_MODE_RECIPIENTS" type="radio">
55-
Show navigation entry for everybody, except me
56-
</NcCheckboxRadioSwitch>
57-
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_ALL" name="NAV_ENTRY_MODE_ALL"
58-
type="radio">
59-
Show navigation entry for everybody
60-
</NcCheckboxRadioSwitch>
61-
<br>
46+
<NcActionCheckbox :checked="showInNavigationDefault" @change="updateDisplayMode">
47+
Show in app list
48+
</NcActionCheckbox>
49+
<p class="nav-display-subtext">
50+
This can be overridden by a per-account preference
51+
</p>
6252
</div>
6353
<div class="row space-R row space-T">
6454
<div class="fix-col-4 end">
@@ -72,7 +62,7 @@
7262
</template>
7363

7464
<script>
75-
import { NcDialog, NcButton, NcIconSvgWrapper, NcCheckboxRadioSwitch } from '@nextcloud/vue'
65+
import { NcDialog, NcButton, NcIconSvgWrapper, NcActionCheckbox } from '@nextcloud/vue'
7666
import { showError } from '@nextcloud/dialogs'
7767
import '@nextcloud/dialogs/style.css'
7868
import NcContextResource from '../../shared/components/ncContextResource/NcContextResource.vue'
@@ -90,7 +80,7 @@ export default {
9080
NcButton,
9181
NcIconSvgWrapper,
9282
NcContextResource,
93-
NcCheckboxRadioSwitch,
83+
NcActionCheckbox,
9484
},
9585
mixins: [svgHelper, permissionBitmask],
9686
props: {
@@ -111,7 +101,7 @@ export default {
111101
description: '',
112102
resources: [],
113103
receivers: [],
114-
displayMode: 'NAV_ENTRY_MODE_HIDDEN',
104+
showInNavigationDefault: false,
115105
}
116106
},
117107
watch: {
@@ -181,19 +171,23 @@ export default {
181171
isUser: true,
182172
key: 'user-' + getCurrentUser().uid,
183173
})
184-
const res = await this.$store.dispatch('insertNewContext', { data, previousReceivers: [], receivers: this.receivers, displayMode: NAV_ENTRY_MODE[this.displayMode] })
174+
const displayMode = this.showInNavigation ? 'NAV_ENTRY_MODE_ALL' : 'NAV_ENTRY_MODE_HIDDEN'
175+
const res = await this.$store.dispatch('insertNewContext', { data, previousReceivers: [], receivers: this.receivers, displayMode: NAV_ENTRY_MODE[displayMode] })
185176
if (res) {
186177
return res.id
187178
} else {
188179
showError(t('tables', 'Could not create new application'))
189180
}
190181
},
182+
updateDisplayMode() {
183+
this.showInNavigation = !this.showInNavigation
184+
},
191185
reset() {
192186
this.title = ''
193187
this.errorTitle = false
194188
this.setIcon(this.randomIcon())
195189
this.customTitleChosen = false
196-
this.displayMode = 'NAV_ENTRY_MODE_HIDDEN'
190+
this.showInNavigationDefault = false
197191
},
198192
},
199193
}
@@ -207,5 +201,13 @@ export default {
207201
display: inline-flex;
208202
align-items: center;
209203
}
204+
205+
.nav-display-subtext {
206+
color: var(--color-text-maxcontrast)
207+
}
208+
209+
li {
210+
list-style: none;
211+
}
210212
}
211213
</style>

src/modules/modals/EditContext.vue

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,14 @@
3939
<NcContextResource :resources.sync="resources" :receivers.sync="receivers" />
4040
</div>
4141
<div class="row space-T">
42-
<div>
43-
{{ t('tables', 'Navigation bar display') }}
44-
</div>
45-
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_HIDDEN"
46-
name="NAV_ENTRY_MODE_HIDDEN" type="radio">
47-
Hide navigation entry for everybody
48-
</NcCheckboxRadioSwitch>
49-
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_RECIPIENTS"
50-
name="NAV_ENTRY_MODE_RECIPIENTS" type="radio">
51-
Show navigation entry for everybody, except me
52-
</NcCheckboxRadioSwitch>
53-
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_ALL" name="NAV_ENTRY_MODE_ALL"
54-
type="radio">
55-
Show navigation entry for everybody
56-
</NcCheckboxRadioSwitch>
57-
<br>
42+
<NcActions>
43+
<NcActionCheckbox :checked="showInNavigationDefault" @change="updateDisplayMode">
44+
Show in app list
45+
</NcActionCheckbox>
46+
</NcActions>
47+
<p class="nav-display-subtext">
48+
This can be overridden by a per-account preference
49+
</p>
5850
</div>
5951
<div class="row space-T">
6052
<div class="fix-col-4 space-T justify-between">
@@ -79,7 +71,7 @@
7971
</template>
8072

8173
<script>
82-
import { NcDialog, NcButton, NcIconSvgWrapper, NcCheckboxRadioSwitch } from '@nextcloud/vue'
74+
import { NcDialog, NcButton, NcIconSvgWrapper, NcActionCheckbox } from '@nextcloud/vue'
8375
import { showError, showSuccess } from '@nextcloud/dialogs'
8476
import { getCurrentUser } from '@nextcloud/auth'
8577
import '@nextcloud/dialogs/style.css'
@@ -100,7 +92,7 @@ export default {
10092
NcIconPicker,
10193
NcIconSvgWrapper,
10294
NcContextResource,
103-
NcCheckboxRadioSwitch,
95+
NcActionCheckbox,
10496
},
10597
mixins: [svgHelper, permissionBitmask, permissionsMixin],
10698
props: {
@@ -129,7 +121,7 @@ export default {
129121
PERMISSION_UPDATE,
130122
PERMISSION_DELETE,
131123
prepareDeleteContext: false,
132-
displayMode: 'NAV_ENTRY_MODE_HIDDEN', // TODO: get the actual saved display mode
124+
showInNavigationDefault: false,
133125
}
134126
},
135127
computed: {
@@ -154,6 +146,7 @@ export default {
154146
this.description = context.description
155147
this.resources = context ? this.getContextResources(context) : []
156148
this.receivers = context ? this.getContextReceivers(context) : []
149+
this.showInNavigationDefault = this.getNavDisplay(context)
157150
}
158151
},
159152
},
@@ -194,7 +187,8 @@ export default {
194187
isUser: true,
195188
key: 'user-' + getCurrentUser().uid,
196189
})
197-
const res = await this.$store.dispatch('updateContext', { id: this.contextId, data, previousReceivers: Object.values(context.sharing), receivers: this.receivers })
190+
const displayMode = this.showInNavigation ? 'NAV_ENTRY_MODE_ALL' : 'NAV_ENTRY_MODE_HIDDEN'
191+
const res = await this.$store.dispatch('updateContext', { id: this.contextId, data, previousReceivers: Object.values(context.sharing), receivers: this.receivers, displayMode: NAV_ENTRY_MODE[displayMode] })
198192
if (res) {
199193
showSuccess(t('tables', 'Updated application "{contextTitle}".', { contextTitle: this.title }))
200194
this.actionCancel()
@@ -210,15 +204,15 @@ export default {
210204
this.resources = context ? this.getContextResources(context) : []
211205
this.receivers = context ? this.getContextReceivers(context) : []
212206
this.prepareDeleteContext = false
207+
this.showInNavigationDefault = this.getNavDisplay(context)
213208
},
214-
getDisplayMode(context) {
209+
getNavDisplay(context) {
215210
const shares = Object.keys(context.sharing || {})
216211
if (shares.length) {
217-
print('vals', context.sharing[shares[0]])
218212
const displayMode = context.sharing[shares[0]].display_mode_default
219-
return Object.keys(NAV_ENTRY_MODE).find(key => NAV_ENTRY_MODE[key] === displayMode)
213+
return displayMode !== 0
220214
}
221-
return 'NAV_ENTRY_MODE_HIDDEN'
215+
return false
222216
},
223217
getContextReceivers(context) {
224218
let sharing = Object.values(context.sharing)
@@ -276,6 +270,9 @@ export default {
276270
}
277271
278272
},
273+
updateDisplayMode() {
274+
this.showInNavigation = !this.showInNavigation
275+
},
279276
actionTransfer() {
280277
emit('tables:context:edit', null)
281278
emit('tables:context:transfer', this.localContext)
@@ -296,4 +293,12 @@ export default {
296293
padding-inline: 0 !important;
297294
max-width: 100%;
298295
}
296+
297+
.nav-display-subtext {
298+
color: var(--color-text-maxcontrast)
299+
}
300+
301+
li {
302+
list-style: none;
303+
}
299304
</style>

src/modules/navigation/partials/NavigationContextItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
{{ t('tables', 'Delete application') }}
3737
</NcActionButton>
3838
<NcActionCheckbox :checked="showInNavigation" @change="updateDisplayMode">
39-
Show in Navigation
39+
Show in app list
4040
</NcActionCheckbox>
4141
</template>
4242
</NcAppNavigationItem>

src/store/store.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,11 @@ export default new Vuex.Store({
410410
commit('setLoading', { key: 'contexts', value: false })
411411
return res.data.ocs.data
412412
},
413-
async updateContext({ state, commit, dispatch }, { id, data, previousReceivers, receivers }) {
413+
async updateContext({ state, commit, dispatch }, { id, data, previousReceivers, receivers, displayMode }) {
414414
let res = null
415415
try {
416416
res = await axios.put(generateOcsUrl('/apps/tables/api/2/contexts/' + id), data)
417-
await dispatch('shareContext', { id, previousReceivers, receivers })
417+
await dispatch('shareContext', { id, previousReceivers, receivers, displayMode })
418418

419419
} catch (e) {
420420
displayError(e, t('tables', 'Could not update application.'))

0 commit comments

Comments
 (0)