Skip to content

Commit

Permalink
Merge pull request #318 from penguin-statistics/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao authored May 16, 2020
2 parents 13f1bbb + af50795 commit aaae806
Show file tree
Hide file tree
Showing 30 changed files with 863 additions and 309 deletions.
6 changes: 3 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"root": true,
"globals": {
"GIT_COMMIT": true,
"workbox": true
"GIT_COMMIT": true
},
"env": {
"node": true
Expand All @@ -15,7 +14,8 @@
"no-console": "off",
"vuetify/no-deprecated-classes": "error",
"vuetify/grid-unknown-attributes": "error",
"vuetify/no-legacy-grid": "error"
"vuetify/no-legacy-grid": "error",
"vue/no-v-html": "off"
},
"parserOptions": {
"parser": "babel-eslint"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "penguin-stats-frontend",
"version": "1.1.11",
"version": "3.0.1",
"private": true,
"homepage": "https://github.com/penguin-statistics/frontend-v2#readme",
"bugs": {
Expand Down Expand Up @@ -49,7 +49,7 @@
},
"devDependencies": {
"@kazupon/vue-i18n-loader": "^0.3.0",
"@mdi/font": "^3.8.95",
"@mdi/font": "4",
"@vue/cli-plugin-babel": "^3.9.0",
"@vue/cli-plugin-eslint": "^3.9.0",
"@vue/cli-service": "^3.9.0",
Expand Down
16 changes: 6 additions & 10 deletions src/components/advancedQuery/QueryBuilder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,14 @@
</v-btn>
</div>
<div class="flex-column pt-2">
<QuerySelectorItem
v-model="query.item"
:disabled="!!query.stage"
/>
<QuerySelectorStage
v-model="query.stage"
:disabled="!!query.item"
/>
<QuerySelectorItem v-model="query.item" />
<QuerySelectorStage v-model="query.stage" />

<v-divider class="my-4" />

<QuerySelectorTimeRange v-model="query.timeRange" />
<!-- <QuerySelectorServer v-model="query.server" />-->
<QuerySelectorServer v-model="query.server" />
<QuerySelectorSource v-model="query.source" />
</div>
</v-card-text>
</v-window-item>
Expand Down Expand Up @@ -114,11 +109,12 @@
import QuerySelectorStage from "@/components/advancedQuery/selectors/QuerySelectorStage";
import QuerySelectorTimeRange from "@/components/advancedQuery/selectors/QuerySelectorTimeRange";
import QuerySelectorServer from "@/components/advancedQuery/selectors/QuerySelectorServer";
import QuerySelectorSource from "@/components/advancedQuery/selectors/QuerySelectorSource";
export default {
name: "QueryBuilder",
// eslint-disable-next-line vue/no-unused-components
components: {QuerySelectorItem, QuerySelectorStage, QuerySelectorTimeRange, QuerySelectorServer},
components: {QuerySelectorSource, QuerySelectorItem, QuerySelectorStage, QuerySelectorTimeRange, QuerySelectorServer},
props: {
value: {
type: Array,
Expand Down
20 changes: 7 additions & 13 deletions src/components/advancedQuery/QueryMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<v-row
class="fill-height"
align="start"
no-gutters
>
<v-col
cols="12"
Expand Down Expand Up @@ -30,7 +31,6 @@
</template>

<script>
import validator from "@/utils/validator";
import QueryResults from "@/components/advancedQuery/QueryResults";
import QueryBuilder from "@/components/advancedQuery/QueryBuilder";
Expand All @@ -50,25 +50,19 @@
queries: [
{
stage: undefined,
item: undefined,
item: [],
timeRange: undefined,
server: undefined,
server: this.$store.getters["dataSource/server"],
source: "global",
}
]
}
},
computed: {
builderProps() {
return {
queries: this.queries
}
}
},
created () {
// rehydrate preset settings
if (this.preset && validator.exclusive(this.preset.stage, this.preset.item)) {
if (this.preset.stage) return this.queries[0].stage = this.preset.stage
if (this.preset.item) return this.queries[0].item = this.preset.item
if (this.preset) {
if (this.preset.stage) this.queries[0].stage = this.preset.stage
if (this.preset.item) this.queries[0].item = this.preset.item
}
},
}
Expand Down
116 changes: 116 additions & 0 deletions src/components/advancedQuery/selectors/MultiItemSelector.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<template>
<div v-if="items">
<div
v-for="(category, name) in items"
:key="name"
class="d-flex flex-column"
>
<div class="ml-2 my-2">
{{ $t(`items.categories.${name}`) }}
</div>
<div class="d-flex flex-wrap justify-start">
<div
v-for="item in category"
:key="item.itemId"
class="d-flex flex-column align-center item-list-item-wrapper"
>
<v-badge
bordered
bottom
overlap

:offset-x="16"
:offset-y="20"
:color="states[item.itemId] ? 'green darken-1' : 'red darken-1'"
:icon="states[item.itemId] ? 'mdi-check' : 'mdi-close'"
:value="states[item.itemId]"
class="item-list-item-avatar"
>
<span
class="transition-all cursor-pointer"
:style="{'filter': states[item.itemId] ? 'drop-shadow(0 0 5px rgba(255, 255, 255, .7))' : 'none'}"
@click.left="select(item.itemId)"
@click.right.prevent="select(item.itemId, true)"
>
<Item
:item="item"
disable-link
/>
</span>
</v-badge>
</div>
</div>
</div>
</div>
</template>

<script>
import get from "@/utils/getters";
import Item from "@/components/global/Item";
export default {
name: "MultiItemSelector",
components: {Item},
props: {
value: {
type: Array,
required: true
}
},
computed: {
states () {
const states = {};
for (const item of get.items.all()) {
// have item or not = has been selected or not
this.$set(states, item.itemId, !!~this.value.indexOf(item.itemId))
}
return states
},
items () {
const all = get.items.all();
const categories = ["MATERIAL", "CARD_EXP", "FURN", "ACTIVITY_ITEM"];
const results = {};
for (const category of categories) {
results[category] = all.filter(el => el.itemType === category);
// move 3003 to the last member
results[category].sort((a, b) => {
if (a.itemId === "3003") return 1;
if (b.itemId === "3003") return -1;
return a.sortId - b.sortId;
});
}
return results;
}
},
methods: {
select (itemId, forceFalse = false) {
if (~this.value.indexOf(itemId) || forceFalse) {
this.$emit('input', this.value.filter(el => el !== itemId))
} else {
this.$emit('input', [...this.value, itemId])
}
}
}
}
</script>

<style scoped>
.item-list-item-wrapper {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-width: 62px;
margin: 4px 0;
}
.item-list-wrapper {
display: flex;
flex-direction: column;
}
.item-list {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
}
</style>
49 changes: 19 additions & 30 deletions src/components/advancedQuery/selectors/QuerySelectorItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<template v-slot:activator="{ on }">
<v-expand-x-transition>
<v-icon
v-if="value"
v-if="value.length"
v-on="on"
>
mdi-treasure-chest
Expand All @@ -33,31 +33,25 @@
</v-card>
</v-tooltip>


<v-btn
class="flex-grow-1"
:class="{'mx-1': value}"
:class="{'mx-1': value.length}"
large
:disabled="disabled"
v-on="on"
>
<ItemById
v-if="value"
:id="value"
:key="value"
/>
<div
v-else
class="d-flex align-center"
<v-icon
left
v-on="on"
>
<v-icon left>
mdi-treasure-chest
</v-icon>
{{ $t('query.selector.item.title') }}
</div>
mdi-treasure-chest
</v-icon>

{{ $t('query.selector.item.title') }} (selected {{ value.length }})
</v-btn>

<v-expand-x-transition>
<div v-if="value">
<div v-if="value.length">
<v-btn
icon
@click="clear"
Expand All @@ -75,9 +69,10 @@
<v-card-title class="title">
{{ $t('query.selector.item.title') }}
</v-card-title>
<ItemSelector
<MultiItemSelector
class="px-4 pb-4"
@select="select"
:value="value"
@input="e => $emit('input', e)"
/>
<v-divider />
<v-card-actions>
Expand All @@ -94,16 +89,15 @@
</template>

<script>
import ItemSelector from "@/components/stats/ItemSelector";
import ItemById from "@/components/global/ItemById";
import MultiItemSelector from "@/components/advancedQuery/selectors/MultiItemSelector";
export default {
name: "QuerySelectorItem",
components: {ItemSelector, ItemById},
components: {MultiItemSelector},
props: {
value: {
type: String,
type: Array,
default () {
return null
return []
}
},
disabled: {
Expand All @@ -115,17 +109,12 @@
},
data() {
return {
search: "",
dialog: false
}
},
methods: {
select (id) {
this.$emit('input', id);
this.dialog = false;
},
clear () {
this.$emit('input', null)
this.$emit('input', [])
}
}
}
Expand Down
Loading

0 comments on commit aaae806

Please sign in to comment.