Skip to content

Commit

Permalink
Merge pull request #412 from nextcloud/privacy
Browse files Browse the repository at this point in the history
Add support for tasks privacy settings
  • Loading branch information
raimund-schluessler authored May 17, 2019
2 parents 8126a75 + 9c405ad commit 66967de
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
5 changes: 5 additions & 0 deletions css/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,11 @@
margin-left: auto;
right: 22px;
}

&.icon-privacy {
opacity: 1;
cursor: unset;
}

&.detail-save {
display: none;
Expand Down
1 change: 1 addition & 0 deletions img/src/color/privacy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 33 additions & 1 deletion src/components/TheDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -547,6 +574,7 @@ export default {
'setStart',
'toggleAllDay',
'moveTask',
'setClassification',
]),

removeTask: function() {
Expand Down Expand Up @@ -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.
*
Expand Down
15 changes: 15 additions & 0 deletions src/models/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down
24 changes: 24 additions & 0 deletions src/store/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 66967de

Please sign in to comment.