rename rule set to rule
This commit is contained in:
@@ -79,7 +79,7 @@ export type MainLedgerResponseTypeEnum = typeof MainLedgerResponseTypeEnum[keyof
|
|||||||
|
|
||||||
export interface RuleBookResponse {
|
export interface RuleBookResponse {
|
||||||
'characterId': number;
|
'characterId': number;
|
||||||
'ruleSets': { [key: string]: RuleSetResponse; };
|
'rules': { [key: string]: RuleResponse; };
|
||||||
}
|
}
|
||||||
export interface RuleClauseResponse {
|
export interface RuleClauseResponse {
|
||||||
'rate': RuleClauseResponseRateEnum;
|
'rate': RuleClauseResponseRateEnum;
|
||||||
@@ -97,11 +97,11 @@ export const RuleClauseResponseRateEnum = {
|
|||||||
|
|
||||||
export type RuleClauseResponseRateEnum = typeof RuleClauseResponseRateEnum[keyof typeof RuleClauseResponseRateEnum];
|
export type RuleClauseResponseRateEnum = typeof RuleClauseResponseRateEnum[keyof typeof RuleClauseResponseRateEnum];
|
||||||
|
|
||||||
export interface RuleSetResponse {
|
export interface RuleResponse {
|
||||||
'rules': Array<RuleClauseResponse>;
|
'rules': Array<RuleClauseResponse>;
|
||||||
}
|
}
|
||||||
export interface SetCharacterRuleBookRequest {
|
export interface SetCharacterRuleBookRequest {
|
||||||
'ruleSets': { [key: string]: RuleSetResponse; };
|
'rules': { [key: string]: RuleResponse; };
|
||||||
}
|
}
|
||||||
export interface UpdateCombinedLedgerRequest {
|
export interface UpdateCombinedLedgerRequest {
|
||||||
'name': string;
|
'name': string;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {Character, CharacterLabel, useCharactersStore} from "@/characters";
|
|||||||
import {useRoute} from "vue-router";
|
import {useRoute} from "vue-router";
|
||||||
import {ref, watch, watchEffect} from "vue";
|
import {ref, watch, watchEffect} from "vue";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {activityTypes, findByCharacterId, RuleBook, RuleSetInput, setCharacterRuleBook} from "@/rules";
|
import {activityTypes, findByCharacterId, RuleBook, RuleInput, setCharacterRuleBook} from "@/rules";
|
||||||
|
|
||||||
const {findById: findCharacterById} = useCharactersStore();
|
const {findById: findCharacterById} = useCharactersStore();
|
||||||
const character = ref<Character>();
|
const character = ref<Character>();
|
||||||
@@ -50,7 +50,7 @@ watch(useRoute(), async route => {
|
|||||||
<div v-if="ruleBook" class="flex-col">
|
<div v-if="ruleBook" class="flex-col">
|
||||||
<div class="flex-col grow border-b-1" v-for="activityType in activityTypes" :key="activityType.key">
|
<div class="flex-col grow border-b-1" v-for="activityType in activityTypes" :key="activityType.key">
|
||||||
<span>{{ activityType.name }}</span>
|
<span>{{ activityType.name }}</span>
|
||||||
<RuleSetInput v-model="ruleBook.ruleSets[activityType.key]" />
|
<RuleInput v-model="ruleBook.rules[activityType.key]" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
import {RuleClauseResponse, RuleClauseResponseRateEnum, RuleSetResponse} from "@/generated/mammon";
|
import {RuleClauseResponse, RuleClauseResponseRateEnum, RuleResponse} from "@/generated/mammon";
|
||||||
import RuleClauseInput from "@/rules/RuleClauseInput.vue";
|
import RuleClauseInput from "@/rules/RuleClauseInput.vue";
|
||||||
import {computed, useTemplateRef} from "vue";
|
import {computed, useTemplateRef} from "vue";
|
||||||
import {Bars4Icon, PlusIcon, TrashIcon} from '@heroicons/vue/24/outline';
|
import {Bars4Icon, PlusIcon, TrashIcon} from '@heroicons/vue/24/outline';
|
||||||
import {useSortable} from "@vueuse/integrations/useSortable";
|
import {useSortable} from "@vueuse/integrations/useSortable";
|
||||||
|
|
||||||
const ruleSet = defineModel<RuleSetResponse>();
|
const rule = defineModel<RuleResponse>();
|
||||||
const rules = computed<RuleClauseResponse[]>({
|
const rules = computed<RuleClauseResponse[]>({
|
||||||
get: () => ruleSet.value && ruleSet.value.rules ? ruleSet.value.rules : [],
|
get: () => rule.value && rule.value.rules ? rule.value.rules : [],
|
||||||
set: value => ruleSet.value = {rules: value}
|
set: value => rule.value = {rules: value}
|
||||||
})
|
})
|
||||||
|
|
||||||
const addRule = () => {
|
const addRule = () => {
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
export * from "./rules";
|
export * from "./rules";
|
||||||
|
|
||||||
export {default as RuleSetInput} from './RuleSetInput.vue';
|
export {default as RuleInput} from './RuleInput.vue';
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
import {ruleBookControllerApi} from "@/mammon";
|
import {ruleBookControllerApi} from "@/mammon";
|
||||||
import {RuleBookResponse, RuleClauseResponseRateEnum, RuleSetResponse} from "@/generated/mammon";
|
import {RuleBookResponse, RuleClauseResponseRateEnum, RuleResponse} from "@/generated/mammon";
|
||||||
|
|
||||||
export const activityTypes = {
|
export const activityTypes = {
|
||||||
itemBought: {key: "ITEM_BOUGHT", name: "Item Bought"},
|
itemBought: {key: "ITEM_BOUGHT", name: "Item Bought"},
|
||||||
@@ -10,7 +10,7 @@ export const activityTypes = {
|
|||||||
|
|
||||||
export type Activity = { key: ActivityType, name: string }
|
export type Activity = { key: ActivityType, name: string }
|
||||||
export type ActivityType = typeof activityTypes[keyof typeof activityTypes]['key'];
|
export type ActivityType = typeof activityTypes[keyof typeof activityTypes]['key'];
|
||||||
export type RuleBook = RuleBookResponse & { ruleSets: { [key: ActivityType]: RuleSetResponse; } }
|
export type RuleBook = RuleBookResponse & { rules: { [key: ActivityType]: RuleResponse; } }
|
||||||
|
|
||||||
export const ratesTypes = {
|
export const ratesTypes = {
|
||||||
None: {key: "NONE", name: "0 ISK"},
|
None: {key: "NONE", name: "0 ISK"},
|
||||||
@@ -24,7 +24,7 @@ export type Rate = { key: RuleClauseResponseRateEnum, name: string }
|
|||||||
|
|
||||||
export const findByCharacterId = (characterId: number): Promise<RuleBook> => ruleBookControllerApi.findByCharacterId(characterId)
|
export const findByCharacterId = (characterId: number): Promise<RuleBook> => ruleBookControllerApi.findByCharacterId(characterId)
|
||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.catch(() => ({characterId, ruleSets: {}}));
|
.catch(() => ({characterId, rules: {}}));
|
||||||
|
|
||||||
export const setCharacterRuleBook = (characterId: number, ruleBook: RuleBook): Promise<RuleBook> => ruleBookControllerApi.setCharacterRuleBook(characterId, ruleBook)
|
export const setCharacterRuleBook = (characterId: number, ruleBook: RuleBook): Promise<RuleBook> => ruleBookControllerApi.setCharacterRuleBook(characterId, ruleBook)
|
||||||
.then(response => response.data);
|
.then(response => response.data);
|
||||||
Reference in New Issue
Block a user