-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1540 from nextcloud/feature/107/categories
Add support for categories
- Loading branch information
Showing
12 changed files
with
502 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
src/components/Editor/Properties/PropertySelectMultiple.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2019 Georg Ehrke <oc.list@georgehrke.com> | ||
- | ||
- @author Georg Ehrke <[email protected]> | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
- This program is free software: you can redistribute it and/or modify | ||
- it under the terms of the GNU Affero General Public License as | ||
- published by the Free Software Foundation, either version 3 of the | ||
- License, or (at your option) any later version. | ||
- | ||
- This program is distributed in the hope that it will be useful, | ||
- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
- GNU Affero General Public License for more details. | ||
- | ||
- You should have received a copy of the GNU Affero General Public License | ||
- along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
- | ||
--> | ||
|
||
<template> | ||
<div v-if="display" class="property-select-multiple"> | ||
<div | ||
class="property-select-multiple__icon" | ||
:class="icon" | ||
:title="readableName" /> | ||
|
||
<div | ||
class="property-select-multiple__input" | ||
:class="{ 'property-select-multiple__input--readonly': isReadOnly }"> | ||
<Multiselect | ||
v-if="!isReadOnly" | ||
:options="options" | ||
:searchable="true" | ||
:placeholder="placeholder" | ||
:tag-placeholder="tagPlaceholder" | ||
:allow-empty="true" | ||
:title="readableName" | ||
:value="value" | ||
:multiple="true" | ||
:taggable="true" | ||
@select="selectValue" | ||
@tag="selectValue" | ||
@remove="unselectValue"> | ||
<template v-if="coloredOptions" #tag="scope"> | ||
<PropertySelectMultipleColoredTag v-bind="scope" /> | ||
</template> | ||
<template v-if="coloredOptions" #option="scope"> | ||
<PropertySelectMultipleColoredOption v-bind="scope" /> | ||
</template> | ||
</Multiselect> | ||
<!-- eslint-disable-next-line vue/singleline-html-element-content-newline --> | ||
<div v-else class="property-select-multiple-colored-tag-wrapper"> | ||
<PropertySelectMultipleColoredTag | ||
v-for="singleValue in value" | ||
:key="singleValue" | ||
:option="singleValue" /> | ||
</div> | ||
</div> | ||
|
||
<div | ||
v-if="hasInfo" | ||
v-tooltip="info" | ||
class="property-select-multiple__info icon-details" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import PropertyMixin from '../../../mixins/PropertyMixin' | ||
import { Multiselect } from '@nextcloud/vue' | ||
import PropertySelectMultipleColoredTag from './PropertySelectMultipleColoredTag.vue' | ||
import PropertySelectMultipleColoredOption from './PropertySelectMultipleColoredOption.vue' | ||
|
||
export default { | ||
name: 'PropertySelectMultiple', | ||
components: { | ||
PropertySelectMultipleColoredOption, | ||
PropertySelectMultipleColoredTag, | ||
Multiselect | ||
}, | ||
mixins: [ | ||
PropertyMixin | ||
], | ||
props: { | ||
coloredOptions: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
computed: { | ||
display() { | ||
return !(this.isReadOnly && this.value.length === 0) | ||
}, | ||
options() { | ||
return this.propModel.options | ||
} | ||
}, | ||
methods: { | ||
selectValue(value) { | ||
if (!value) { | ||
return | ||
} | ||
|
||
this.$emit('addSingleValue', value) | ||
}, | ||
unselectValue(value) { | ||
if (!value) { | ||
return | ||
} | ||
|
||
this.$emit('removeSingleValue', value) | ||
} | ||
} | ||
} | ||
</script> |
51 changes: 51 additions & 0 deletions
51
src/components/Editor/Properties/PropertySelectMultipleColoredOption.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2019 Georg Ehrke <oc.list@georgehrke.com> | ||
- | ||
- @author Georg Ehrke <[email protected]> | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
- This program is free software: you can redistribute it and/or modify | ||
- it under the terms of the GNU Affero General Public License as | ||
- published by the Free Software Foundation, either version 3 of the | ||
- License, or (at your option) any later version. | ||
- | ||
- This program is distributed in the hope that it will be useful, | ||
- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
- GNU Affero General Public License for more details. | ||
- | ||
- You should have received a copy of the GNU Affero General Public License | ||
- along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
- | ||
--> | ||
|
||
<template> | ||
<span class="property-select-multiple-colored-tag"> | ||
<div class="property-select-multiple-colored-tag__color-indicator" :style="{ 'background-color': color}" /> | ||
<span class="property-select-multiple-colored-tag__label">{{ option }}</span> | ||
</span> | ||
</template> | ||
|
||
<script> | ||
import { uidToColor } from '../../../utils/uidToColor.js' | ||
|
||
export default { | ||
name: 'PropertySelectMultipleColoredOption', | ||
props: { | ||
option: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
computed: { | ||
colorObject() { | ||
return uidToColor(this.option) | ||
}, | ||
color() { | ||
const color = this.colorObject | ||
return `rgb(${color.r},${color.g},${color.b})` | ||
} | ||
} | ||
} | ||
</script> |
71 changes: 71 additions & 0 deletions
71
src/components/Editor/Properties/PropertySelectMultipleColoredTag.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2019 Georg Ehrke <oc.list@georgehrke.com> | ||
- | ||
- @author Georg Ehrke <[email protected]> | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
- This program is free software: you can redistribute it and/or modify | ||
- it under the terms of the GNU Affero General Public License as | ||
- published by the Free Software Foundation, either version 3 of the | ||
- License, or (at your option) any later version. | ||
- | ||
- This program is distributed in the hope that it will be useful, | ||
- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
- GNU Affero General Public License for more details. | ||
- | ||
- You should have received a copy of the GNU Affero General Public License | ||
- along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
- | ||
--> | ||
|
||
<template> | ||
<span :key="option" class="multiselect__tag" :style="{ 'background-color': color, 'border-color': borderColor, color: textColor }"> | ||
<span>{{ option }}</span> | ||
</span> | ||
</template> | ||
|
||
<script> | ||
import { uidToColor } from '../../../utils/uidToColor.js' | ||
import { generateTextColorForRGB } from '../../../utils/color.js' | ||
|
||
export default { | ||
name: 'PropertySelectMultipleColoredTag', | ||
props: { | ||
option: { | ||
type: String, | ||
required: true | ||
}, | ||
search: { | ||
type: String, | ||
default: undefined | ||
}, | ||
remove: { | ||
type: Function, | ||
default: () => {} | ||
} | ||
}, | ||
computed: { | ||
colorObject() { | ||
return uidToColor(this.option) | ||
}, | ||
borderColor() { | ||
const color = this.colorObject | ||
return `rgb(${color.r},${color.g},${color.b})` | ||
}, | ||
color() { | ||
const color = this.colorObject | ||
return `rgba(${color.r},${color.g},${color.b},0.7)` | ||
}, | ||
textColor() { | ||
const color = this.colorObject | ||
return generateTextColorForRGB({ | ||
red: color.r, | ||
green: color.g, | ||
blue: color.b | ||
}) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Calendar App | ||
* | ||
* @copyright 2019 Georg Ehrke <[email protected]> | ||
* | ||
* @author Georg Ehrke | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
import { translate } from '@nextcloud/l10n' | ||
|
||
export default () => { | ||
// This list was taken from https://tools.ietf.org/html/rfc5545#section-5 | ||
return [ | ||
translate('calendar', 'Anniversary'), | ||
translate('calendar', 'Appointment'), | ||
translate('calendar', 'Business'), | ||
translate('calendar', 'Education'), | ||
translate('calendar', 'Holiday'), | ||
translate('calendar', 'Meeting'), | ||
translate('calendar', 'Miscellaneous'), | ||
translate('calendar', 'Non-working hours'), | ||
translate('calendar', 'Not in office'), | ||
translate('calendar', 'Personal'), | ||
translate('calendar', 'Phone call'), | ||
translate('calendar', 'Sick day'), | ||
translate('calendar', 'Special occasion'), | ||
translate('calendar', 'Travel'), | ||
translate('calendar', 'Vacation') | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.