Skip to content

Commit

Permalink
feat: force onlyCurrent to be disabled when on a stage that is not cu…
Browse files Browse the repository at this point in the history
…rrently opening
  • Loading branch information
GalvinGao committed Mar 17, 2023
1 parent 134f9c2 commit c19c225
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
27 changes: 24 additions & 3 deletions src/components/stats/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@
</template>
<template #content>
<v-checkbox
v-model="dataTable.onlyCurrent"
v-model="stageFilterOnlyCurrent"
v-haptic
hide-details
:label="$t('stats.filter.stage.onlyCurrent')"
class="mt-0 pt-0 mr-4"
:class="{ 'mr-2': $vuetify.breakpoint.smAndUp }"
:disabled="forceStageFilterOnlyCurrentDisabled"
/>
</template>
</TitledRow>
Expand Down Expand Up @@ -496,6 +497,12 @@ export default {
default() {
return false
}
},
validStage: {
type: Boolean,
default() {
return false
}
}
},
data() {
Expand Down Expand Up @@ -617,7 +624,7 @@ export default {
if (!this.dataTable.showPermanent) data = data.filter(el => el.stage.stageType !== 'MAIN' && el.stage.stageType !== 'SUB' && el.stage.stageType !== 'DAILY')
if (!this.dataTable.showActivity) data = data.filter(el => el.stage.stageType !== 'ACTIVITY')
} else if (this.type === 'stage') {
if (this.dataTable.onlyCurrent) {
if (this.stageFilterOnlyCurrent) {
data = data.filter(el => {
return el.end === null || el.end > Date.now()
})
Expand All @@ -630,7 +637,21 @@ export default {
if (this.dataTable.onlyOpen) counter++
if (!this.dataTable.showPermanent || !this.dataTable.showActivity) counter++
return counter
}
},
forceStageFilterOnlyCurrentDisabled() {
return !this.validStage
},
stageFilterOnlyCurrent: {
get() {
if (this.forceStageFilterOnlyCurrentDisabled) return false
return this.dataTable.onlyCurrent
},
set(val) {
this.$store.commit('options/changeDataTable', {
onlyCurrent: val
})
}
},
},
watch: {
dataTable: {
Expand Down
16 changes: 9 additions & 7 deletions src/views/Stats/Stage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</h2>
<h1 class="title pt-1 no-wrap--text d-inline-flex align-center">
{{
$t("stats.title", { stage: strings.translate(stage, "code") })
$t("stats.title", {stage: strings.translate(stage, "code")})
}}
</h1>
</div>
Expand Down Expand Up @@ -52,6 +52,7 @@
type="stage"
:trends="trends"
:is-recruit="isRecruit"
:valid-stage="validStage"
class="px-3 px-sm-4 px-md-6 px-lg-6 px-xl-8 pt-0 pb-6"
/>

Expand Down Expand Up @@ -108,7 +109,7 @@ export default {
},
stage() {
const got = get.stages.byStageId(this.selected.stage);
if (!got) return { code: "" };
if (!got) return {code: ""};
return {
...got,
code: strings.translate(got, "code"),
Expand All @@ -133,17 +134,17 @@ export default {
},
validStage() {
return (
!this.zone.isOutdated &&
this.stage.dropInfos &&
existUtils.existence(this.stage, true)
!this.zone.isOutdated &&
this.stage.dropInfos &&
existUtils.existence(this.stage, true)
);
},
isRecruit() {
return this.selected.stage === "recruit";
},
},
methods: {
select({ zone, stage }) {
select({zone, stage}) {
this.selected.zone = zone;
this.selected.stage = stage;
},
Expand All @@ -159,8 +160,9 @@ export default {
.v-table {
background: transparent !important;
}
/*.v-expansion-panel {*/
/* transform: translateY(48px);*/
/* opacity: 0;*/
/*}*/
</style>
</style>

0 comments on commit c19c225

Please sign in to comment.