зеркало из https://github.com/nextcloud/cookbook.git
Prettier fixes and updated CHANGELOG
Signed-off-by: Sebastian Fey <info@sebastianfey.de>
This commit is contained in:
Родитель
13b4d03840
Коммит
9395d53cb3
|
@ -3,6 +3,8 @@
|
|||
### Added
|
||||
- Make recipes searchable through unified search
|
||||
[#611](https://github.com/nextcloud/cookbook/pull/611) @PFischbeck
|
||||
- Enhanced keyword cloud in recipe list with option to hide/show keywords, enlarge area, and ordering alphabetically
|
||||
[#678](https://github.com/nextcloud/cookbook/pull/678) @seyfeb
|
||||
|
||||
### Fixed
|
||||
- Calling reindex
|
||||
|
|
|
@ -56,7 +56,12 @@
|
|||
class="checkbox"
|
||||
/>
|
||||
<label for="tag-cloud">
|
||||
{{ t("cookbook", "Show keyword cloud in recipe lists") }}
|
||||
{{
|
||||
t(
|
||||
"cookbook",
|
||||
"Show keyword cloud in recipe lists"
|
||||
)
|
||||
}}
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -122,7 +127,9 @@ export default {
|
|||
},
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
showTagCloudInRecipeList(newVal, oldVal) {
|
||||
this.$store.dispatch("setShowTagCloudInRecipeList", { showTagCloud: newVal })
|
||||
this.$store.dispatch("setShowTagCloudInRecipeList", {
|
||||
showTagCloud: newVal,
|
||||
})
|
||||
},
|
||||
updateInterval(newVal, oldVal) {
|
||||
// Avoid infinite loop on page load and when reseting value after failed submit
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<div>
|
||||
<RecipeListKeywordCloud
|
||||
v-if="showTagCloudInRecipeList"
|
||||
v-model="keywordFilter" :keywords="rawKeywords"
|
||||
v-model="keywordFilter"
|
||||
:keywords="rawKeywords"
|
||||
:filteredRecipes="filteredRecipes"
|
||||
/>
|
||||
<div id="recipes-submenu" class="recipes-submenu-container">
|
||||
|
@ -62,7 +63,7 @@ export default {
|
|||
components: {
|
||||
Multiselect,
|
||||
RecipeCard,
|
||||
RecipeListKeywordCloud
|
||||
RecipeListKeywordCloud,
|
||||
},
|
||||
props: {
|
||||
recipes: {
|
||||
|
@ -240,7 +241,7 @@ export default {
|
|||
},
|
||||
showTagCloudInRecipeList() {
|
||||
return this.$store.state.localSettings.showTagCloudInRecipeList
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$root.$off("applyRecipeFilter")
|
||||
|
@ -313,7 +314,6 @@ export default {
|
|||
</style>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.recipes-submenu-container {
|
||||
padding-left: 16px;
|
||||
margin-bottom: 0.75ex;
|
||||
|
|
|
@ -8,46 +8,51 @@
|
|||
tag="ul"
|
||||
>
|
||||
<RecipeKeyword
|
||||
v-for="keywordObj in selectedKeywordsWithCount"
|
||||
:key="keywordObj.name"
|
||||
:name="keywordObj.name"
|
||||
:count="keywordObj.count"
|
||||
:title="t('cookbook', 'Toggle keyword')"
|
||||
class="keyword active"
|
||||
@keyword-clicked="keywordClicked(keywordObj)"
|
||||
v-for="keywordObj in selectedKeywordsWithCount"
|
||||
:key="keywordObj.name"
|
||||
:name="keywordObj.name"
|
||||
:count="keywordObj.count"
|
||||
:title="t('cookbook', 'Toggle keyword')"
|
||||
class="keyword active"
|
||||
@keyword-clicked="keywordClicked(keywordObj)"
|
||||
/>
|
||||
<RecipeKeyword
|
||||
v-for="keywordObj in selectableKeywords"
|
||||
:key="keywordObj.name"
|
||||
:name="keywordObj.name"
|
||||
:count="keywordObj.count"
|
||||
:title="t('cookbook', 'Toggle keyword')"
|
||||
class="keyword"
|
||||
@keyword-clicked="keywordClicked(keywordObj)"
|
||||
v-for="keywordObj in selectableKeywords"
|
||||
:key="keywordObj.name"
|
||||
:name="keywordObj.name"
|
||||
:count="keywordObj.count"
|
||||
:title="t('cookbook', 'Toggle keyword')"
|
||||
class="keyword"
|
||||
@keyword-clicked="keywordClicked(keywordObj)"
|
||||
/>
|
||||
<RecipeKeyword
|
||||
v-for="keywordObj in unavailableKeywords"
|
||||
:key="keywordObj.name"
|
||||
:name="keywordObj.name"
|
||||
:count="keywordObj.count"
|
||||
:title="
|
||||
// prettier-ignore
|
||||
t('cookbook','Keyword not contained in visible recipes')
|
||||
"
|
||||
class="keyword disabled"
|
||||
@keyword-clicked="keywordClicked(keywordObj)"
|
||||
v-for="keywordObj in unavailableKeywords"
|
||||
:key="keywordObj.name"
|
||||
:name="keywordObj.name"
|
||||
:count="keywordObj.count"
|
||||
:title="
|
||||
// prettier-ignore
|
||||
t('cookbook','Keyword not contained in visible recipes')
|
||||
"
|
||||
class="keyword disabled"
|
||||
@keyword-clicked="keywordClicked(keywordObj)"
|
||||
/>
|
||||
</transition-group>
|
||||
</div>
|
||||
<div class="settings-buttons">
|
||||
<button class="ordering-button"
|
||||
:title="orderButtonTitle"
|
||||
@click="toggleOrderCriterium">{{ orderButtonText }}</button>
|
||||
<button :class="toggleSizeIcon"
|
||||
:title="t('cookbook','Toggle keyword area size')"
|
||||
@click="toggleCloudSize" />
|
||||
<button
|
||||
class="ordering-button"
|
||||
:title="orderButtonTitle"
|
||||
@click="toggleOrderCriterium"
|
||||
>
|
||||
{{ orderButtonText }}
|
||||
</button>
|
||||
<button
|
||||
:class="toggleSizeIcon"
|
||||
:title="t('cookbook', 'Toggle keyword area size')"
|
||||
@click="toggleCloudSize"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -57,7 +62,7 @@ import RecipeKeyword from "./RecipeKeyword.vue"
|
|||
export default {
|
||||
name: "RecipeListKeywordCloud",
|
||||
components: {
|
||||
RecipeKeyword
|
||||
RecipeKeyword,
|
||||
},
|
||||
props: {
|
||||
/** String-array of all available keywords */
|
||||
|
@ -75,11 +80,11 @@ export default {
|
|||
default: () => [],
|
||||
},
|
||||
},
|
||||
data(){
|
||||
data() {
|
||||
return {
|
||||
isMaximized: false,
|
||||
isOrderedAlphabetically: false,
|
||||
selectedKeywordsBuffer: []
|
||||
selectedKeywordsBuffer: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -89,97 +94,98 @@ export default {
|
|||
},
|
||||
/** Title of the button for ordering the keywords */
|
||||
orderButtonTitle() {
|
||||
return this.isOrderedAlphabetically ? t('cookbook','Order keywords by number of recipes') : t('cookbook','Order keywords alphabetically')
|
||||
return this.isOrderedAlphabetically
|
||||
? t("cookbook", "Order keywords by number of recipes")
|
||||
: t("cookbook", "Order keywords alphabetically")
|
||||
},
|
||||
/**
|
||||
* Which icon to show for the size-toggle button
|
||||
*/
|
||||
toggleSizeIcon() {
|
||||
return this.isMaximized ? "icon-triangle-n" : "icon-triangle-s"
|
||||
return this.isMaximized ? "icon-triangle-n" : "icon-triangle-s"
|
||||
},
|
||||
/**
|
||||
* An array of sorted and unique keywords over all the recipes
|
||||
*/
|
||||
uniqKeywords() {
|
||||
function uniqFilter(value, index, self) {
|
||||
return self.indexOf(value) === index
|
||||
}
|
||||
const rawKWs = [...this.keywords]
|
||||
return rawKWs.sort().filter(uniqFilter)
|
||||
function uniqFilter(value, index, self) {
|
||||
return self.indexOf(value) === index
|
||||
}
|
||||
const rawKWs = [...this.keywords]
|
||||
return rawKWs.sort().filter(uniqFilter)
|
||||
},
|
||||
/**
|
||||
* An array of objects that contain the keywords plus a count of recipes associated with these keywords
|
||||
*/
|
||||
keywordsWithCount() {
|
||||
const $this = this
|
||||
return this.uniqKeywords
|
||||
.map((kw) => ({
|
||||
name: kw,
|
||||
count: $this.keywords.filter((kw2) => kw === kw2).length,
|
||||
}))
|
||||
.sort((k1, k2) => {
|
||||
if(this.isOrderedAlphabetically){
|
||||
return k1.name.toLowerCase() > k2.name.toLowerCase()
|
||||
? 1
|
||||
: -1
|
||||
}
|
||||
// else: order by number of recipe with this keyword (decreasing)
|
||||
if (k1.count !== k2.count) {
|
||||
// Distinguish by number
|
||||
return k2.count - k1.count
|
||||
}
|
||||
// Distinguish by keyword name
|
||||
return k1.name.toLowerCase() > k2.name.toLowerCase()
|
||||
? 1
|
||||
: -1
|
||||
|
||||
})
|
||||
const $this = this
|
||||
return this.uniqKeywords
|
||||
.map((kw) => ({
|
||||
name: kw,
|
||||
count: $this.keywords.filter((kw2) => kw === kw2).length,
|
||||
}))
|
||||
.sort((k1, k2) => {
|
||||
if (this.isOrderedAlphabetically) {
|
||||
return k1.name.toLowerCase() > k2.name.toLowerCase()
|
||||
? 1
|
||||
: -1
|
||||
}
|
||||
// else: order by number of recipe with this keyword (decreasing)
|
||||
if (k1.count !== k2.count) {
|
||||
// Distinguish by number
|
||||
return k2.count - k1.count
|
||||
}
|
||||
// Distinguish by keyword name
|
||||
return k1.name.toLowerCase() > k2.name.toLowerCase()
|
||||
? 1
|
||||
: -1
|
||||
})
|
||||
},
|
||||
/**
|
||||
* An array of keywords that are yet unselected but some visible recipes are associated
|
||||
*/
|
||||
selectableKeywords() {
|
||||
if (this.unselectedKeywords.length === 0) {
|
||||
return []
|
||||
}
|
||||
if (this.unselectedKeywords.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
const $this = this
|
||||
return this.unselectedKeywords.filter((kw) =>
|
||||
$this.filteredRecipes
|
||||
.map(
|
||||
(r) =>
|
||||
r.keywords &&
|
||||
r.keywords.split(",").includes(kw.name)
|
||||
)
|
||||
.reduce((l, r) => l || r, false)
|
||||
)
|
||||
const $this = this
|
||||
return this.unselectedKeywords.filter((kw) =>
|
||||
$this.filteredRecipes
|
||||
.map(
|
||||
(r) =>
|
||||
r.keywords &&
|
||||
r.keywords.split(",").includes(kw.name)
|
||||
)
|
||||
.reduce((l, r) => l || r, false)
|
||||
)
|
||||
},
|
||||
/**
|
||||
* An array of keyword objects that are currently in use for filtering
|
||||
*/
|
||||
selectedKeywordsWithCount() {
|
||||
return this.keywordsWithCount.filter((kw) =>
|
||||
this.selectedKeywordsBuffer.includes(kw.name)
|
||||
)
|
||||
return this.keywordsWithCount.filter((kw) =>
|
||||
this.selectedKeywordsBuffer.includes(kw.name)
|
||||
)
|
||||
},
|
||||
/**
|
||||
* An array of known keywords that are not associated with any visible recipe
|
||||
*/
|
||||
unavailableKeywords() {
|
||||
return this.unselectedKeywords.filter(
|
||||
(kw) => !this.selectableKeywords.includes(kw)
|
||||
)
|
||||
return this.unselectedKeywords.filter(
|
||||
(kw) => !this.selectableKeywords.includes(kw)
|
||||
)
|
||||
},
|
||||
/**
|
||||
* An array of those keyword objects that are currently not in use for filtering
|
||||
*/
|
||||
unselectedKeywords() {
|
||||
return this.keywordsWithCount.filter(
|
||||
(kw) => !this.selectedKeywordsWithCount.includes(kw)
|
||||
)
|
||||
return this.keywordsWithCount.filter(
|
||||
(kw) => !this.selectedKeywordsWithCount.includes(kw)
|
||||
)
|
||||
},
|
||||
},
|
||||
watch:{
|
||||
watch: {
|
||||
/**
|
||||
* Watch array of selected keywords for changes
|
||||
*/
|
||||
|
@ -188,7 +194,7 @@ export default {
|
|||
this.selectedKeywordsBuffer = this.value.slice()
|
||||
},
|
||||
deep: true,
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
|
@ -208,13 +214,12 @@ export default {
|
|||
},
|
||||
toggleOrderCriterium() {
|
||||
this.isOrderedAlphabetically = !this.isOrderedAlphabetically
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.kw-container {
|
||||
position: relative;
|
||||
}
|
||||
|
@ -257,4 +262,4 @@ export default {
|
|||
padding: 2px 6px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
@ -195,7 +195,7 @@ import AppMain from "./components/AppMain.vue"
|
|||
store,
|
||||
router,
|
||||
beforeCreate() {
|
||||
this.$store.commit('initializeStore')
|
||||
this.$store.commit("initializeStore")
|
||||
},
|
||||
}).$mount("#content")
|
||||
})
|
||||
|
|
|
@ -44,14 +44,16 @@ export default new Vuex.Store({
|
|||
// Category which is being updated (name)
|
||||
categoryUpdating: null,
|
||||
localSettings: {
|
||||
showTagCloudInRecipeList: true
|
||||
}
|
||||
showTagCloudInRecipeList: true,
|
||||
},
|
||||
},
|
||||
|
||||
mutations: {
|
||||
initializeStore(state) {
|
||||
if (localStorage.getItem('showTagCloudInRecipeList')) {
|
||||
state.localSettings.showTagCloudInRecipeList = JSON.parse(localStorage.getItem('showTagCloudInRecipeList'))
|
||||
if (localStorage.getItem("showTagCloudInRecipeList")) {
|
||||
state.localSettings.showTagCloudInRecipeList = JSON.parse(
|
||||
localStorage.getItem("showTagCloudInRecipeList")
|
||||
)
|
||||
} else {
|
||||
state.localSettings.showTagCloudInRecipeList = true
|
||||
}
|
||||
|
@ -92,7 +94,7 @@ export default new Vuex.Store({
|
|||
state.savingRecipe = b
|
||||
},
|
||||
setShowTagCloudInRecipeList(state, { b }) {
|
||||
localStorage.setItem("showTagCloudInRecipeList", JSON.stringify(b));
|
||||
localStorage.setItem("showTagCloudInRecipeList", JSON.stringify(b))
|
||||
state.localSettings.showTagCloudInRecipeList = b
|
||||
},
|
||||
setUser(state, { u }) {
|
||||
|
@ -161,8 +163,8 @@ export default new Vuex.Store({
|
|||
setCategoryUpdating(c, { category }) {
|
||||
c.commit("setCategoryUpdating", { c: category })
|
||||
},
|
||||
setShowTagCloudInRecipeList(c, { showTagCloud }){
|
||||
c.commit("setShowTagCloudInRecipeList", { b: showTagCloud})
|
||||
setShowTagCloudInRecipeList(c, { showTagCloud }) {
|
||||
c.commit("setShowTagCloudInRecipeList", { b: showTagCloud })
|
||||
},
|
||||
updateCategoryName(c, { categoryNames }) {
|
||||
const oldName = categoryNames[0]
|
||||
|
|
Загрузка…
Ссылка в новой задаче