Add support for tasks privacy settings

Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
This commit is contained in:
Raimund Schlüßler 2019-05-17 09:56:50 +02:00
parent f8ad462c3c
commit 9c405ad39d
No known key found for this signature in database
GPG Key ID: 036FA7EB1A599178
5 changed files with 78 additions and 1 deletions

View File

@ -858,6 +858,11 @@
margin-left: auto;
right: 22px;
}
&.icon-privacy {
opacity: 1;
cursor: unset;
}
&.detail-save {
display: none;

View File

@ -0,0 +1 @@
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m8 3c-3.11 0-5.927 1.72-8 4.5 2.073 2.78 4.89 4.5 8 4.5s5.927-1.72 8-4.5c-2.073-2.78-4.89-4.5-8-4.5zm0 1.5a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0 1.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z" fill="#4574A9"/></svg>

After

Width:  |  Height:  |  Size: 295 B

View File

@ -164,6 +164,28 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
</div>
</div>
</li>
<li class="section detail-class reactive">
<div v-click-outside="() => finishEditing('class')"
@click="editProperty('class')"
>
<span class="icon icon-color icon-privacy" />
<div class="detail-calendar-container">
<Multiselect
:value="classSelect.find( _ => _.type === task.class )"
:multiple="false"
:allow-empty="false"
track-by="type"
:placeholder="t('tasks', 'Select a classification')"
label="displayName"
:options="classSelect"
:close-on-select="true"
class="multiselect-vue"
@input="changeClass"
@tag="changeClass"
/>
</div>
</div>
</li>
<li :class="[{'editing': edit=='priority', 'date': task.priority>0}, priorityString]"
class="section detail-priority"
>
@ -483,7 +505,12 @@ export default {
step: '00:30',
end: '23:30'
},
categories: []
categories: [],
classSelect: [
{ displayName: t('tasks', 'When shared show full event'), type: 'PUBLIC' },
{ displayName: t('tasks', 'When shared show only busy'), type: 'CONFIDENTIAL' },
{ displayName: t('tasks', 'When shared hide this event'), type: 'PRIVATE' },
],
}
},
computed: {
@ -547,6 +574,7 @@ export default {
'setStart',
'toggleAllDay',
'moveTask',
'setClassification',
]),
removeTask: function() {
@ -710,6 +738,10 @@ export default {
this.tmpTask.due = this.setDatePartial(this.tmpTask.due.clone(), moment(datetime), type)
},
changeClass: function(classification) {
this.setClassification({ task: this.task, classification: classification.type })
},
/**
* Sets partial values of a moment to the values of an other moment.
*

View File

@ -103,6 +103,7 @@ export default class Task {
this._categories = categories ? categories.getValues() : []
this._modified = this.vtodo.getFirstPropertyValue('last-modified')
this._created = this.vtodo.getFirstPropertyValue('created')
this._class = this.vtodo.getFirstPropertyValue('class') || 'PUBLIC'
this._searchQuery = ''
this._matchesSearchQuery = true
@ -450,6 +451,20 @@ export default class Task {
this._created = this.vtodo.getFirstPropertyValue('created')
}
get class() {
return this._class
}
set class(classification) {
if (classification) {
this.vtodo.updatePropertyWithValue('class', classification)
} else {
this.vtodo.removeProperty('class')
}
this.updateLastModified()
this._class = this.vtodo.getFirstPropertyValue('class') || 'PUBLIC'
}
/**
* Checks if the task matches the search query
*

View File

@ -407,6 +407,17 @@ const mutations = {
Vue.set(task, 'priority', priority)
},
/**
* Sets the classification of a task
*
* @param {Object} state The store data
* @param {Task} task The task
* @param {String} classification The classification
*/
setClassification(state, { task, classification }) {
Vue.set(task, 'class', classification)
},
/**
* Sets the due date of a task
*
@ -818,6 +829,19 @@ const actions = {
context.dispatch('scheduleTaskUpdate', task)
},
/**
* Sets the classification of a task
*
* @param {Object} context The store context
* @param {Task} task The task to update
*/
async setClassification(context, { task, classification }) {
// check classification to comply with RFC5545 values
classification = (['PUBLIC', 'PRIVATE', 'CONFIDENTIAL'].indexOf(classification) > -1) ? classification : null
context.commit('setClassification', { task: task, classification: classification })
context.dispatch('scheduleTaskUpdate', task)
},
/**
* Sets the due date of a task
*