character rule book front

This commit is contained in:
Sirttas
2026-05-31 18:19:45 +02:00
parent ba81d7b6a8
commit 9310397320
10 changed files with 484 additions and 119 deletions
+96 -13
View File
@@ -9,7 +9,7 @@ paths:
/rule-books/{ruleBookId}:
get:
tags:
- rule-book-controller
- rule-book
operationId: findRuleBookById
parameters:
- name: ruleBookId
@@ -31,7 +31,7 @@ paths:
$ref: "#/components/schemas/RuleBookResponse"
put:
tags:
- rule-book-controller
- rule-book
operationId: updateRuleBook
parameters:
- name: ruleBookId
@@ -60,7 +60,7 @@ paths:
/ledgers/main/{ledgerId}:
put:
tags:
- ledger-controller
- ledger
operationId: updateMainLedger
parameters:
- name: ledgerId
@@ -89,7 +89,7 @@ paths:
/ledgers/combined/{ledgerId}:
put:
tags:
- ledger-controller
- ledger
operationId: updateCombinedLedger
parameters:
- name: ledgerId
@@ -115,10 +115,61 @@ paths:
'*/*':
schema:
$ref: "#/components/schemas/CombinedLedgerResponse"
/characters/{characterId}/rule-book:
get:
tags:
- character-rule-book
operationId: findCharacterRuleBookByCharacterId
parameters:
- name: characterId
in: path
required: true
schema:
type: integer
format: int64
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/CharacterRuleBookResponse"
put:
tags:
- character-rule-book
operationId: setCharacterRuleBookForCharacter
parameters:
- name: characterId
in: path
required: true
schema:
type: integer
format: int64
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SetCharacterRuleBookRequest"
required: true
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/CharacterRuleBookResponse"
/rule-books:
get:
tags:
- rule-book-controller
- rule-book
operationId: findAllRuleBooks
responses:
"404":
@@ -135,7 +186,7 @@ paths:
$ref: "#/components/schemas/RuleBookResponse"
post:
tags:
- rule-book-controller
- rule-book
operationId: createRuleBook
requestBody:
content:
@@ -157,7 +208,7 @@ paths:
/process-activities:
post:
tags:
- processing-controller
- processing
operationId: processNewActivities
responses:
"404":
@@ -169,7 +220,7 @@ paths:
/ledgers/main:
post:
tags:
- ledger-controller
- ledger
operationId: createMainLedger
requestBody:
content:
@@ -191,7 +242,7 @@ paths:
/ledgers/combined:
post:
tags:
- ledger-controller
- ledger
operationId: createCombinedLedger
requestBody:
content:
@@ -213,7 +264,7 @@ paths:
/activity/fetch/{characterId}:
post:
tags:
- activity-controller
- activity
operationId: fetchNewActivitiesForCharacter
parameters:
- name: characterId
@@ -232,7 +283,7 @@ paths:
/ledgers:
get:
tags:
- ledger-controller
- ledger
operationId: findAllLedgers
responses:
"404":
@@ -252,7 +303,7 @@ paths:
/ledgers/{ledgerId}:
get:
tags:
- ledger-controller
- ledger
operationId: findLedgerById
parameters:
- name: ledgerId
@@ -277,7 +328,7 @@ paths:
/characters:
get:
tags:
- character-controller
- character
operationId: findAllCharacters
responses:
"404":
@@ -426,6 +477,38 @@ components:
- ledgerId
- memberLedgerIds
- name
SetCharacterRuleBookRequest:
type: object
properties:
ruleBookId:
type: string
format: uuid
bindings:
type: object
additionalProperties:
type: string
format: uuid
required:
- bindings
- ruleBookId
CharacterRuleBookResponse:
type: object
properties:
characterId:
type: integer
format: int64
ruleBookId:
type: string
format: uuid
bindings:
type: object
additionalProperties:
type: string
format: uuid
required:
- bindings
- characterId
- ruleBookId
CreateRuleBookRequest:
type: object
properties:
+3 -3
View File
@@ -1,4 +1,4 @@
import {activityControllerApi, characterControllerApi} from "@/mammon";
import {activityApi, characterApi} from "@/mammon";
import {defineStore} from "pinia";
import {ref} from "vue";
import {CharacterResponse} from "@/generated/mammon";
@@ -18,9 +18,9 @@ export const useCharactersStore = defineStore('characters', () => {
return character;
}
const reloadActivities = (characterId: number): Promise<void> => activityControllerApi.fetchNewActivitiesForCharacter(characterId) as Promise<void>;
const reloadActivities = (characterId: number): Promise<void> => activityApi.fetchNewActivitiesForCharacter(characterId) as Promise<void>;
const refresh = () => characterControllerApi.findAllCharacters().then(response => characters.value = response.data);
const refresh = () => characterApi.findAllCharacters().then(response => characters.value = response.data);
refresh();
+254 -76
View File
@@ -27,6 +27,11 @@ export interface CharacterResponse {
'characterId': number;
'name': string;
}
export interface CharacterRuleBookResponse {
'characterId': number;
'ruleBookId': string;
'bindings': { [key: string]: string; };
}
export interface CombinedLedgerResponse extends LedgerResponse {
'ledgerId': string;
'name': string;
@@ -107,6 +112,10 @@ export type RuleClauseResponseRateEnum = typeof RuleClauseResponseRateEnum[keyof
export interface RuleResponse {
'rules': Array<RuleClauseResponse>;
}
export interface SetCharacterRuleBookRequest {
'ruleBookId': string;
'bindings': { [key: string]: string; };
}
export interface UpdateCombinedLedgerRequest {
'name': string;
'memberLedgerIds': Array<string>;
@@ -121,9 +130,9 @@ export interface UpdateRuleBookRequest {
}
/**
* ActivityControllerApi - axios parameter creator
* ActivityApi - axios parameter creator
*/
export const ActivityControllerApiAxiosParamCreator = function (configuration?: Configuration) {
export const ActivityApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
@@ -161,10 +170,10 @@ export const ActivityControllerApiAxiosParamCreator = function (configuration?:
};
/**
* ActivityControllerApi - functional programming interface
* ActivityApi - functional programming interface
*/
export const ActivityControllerApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = ActivityControllerApiAxiosParamCreator(configuration)
export const ActivityApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = ActivityApiAxiosParamCreator(configuration)
return {
/**
*
@@ -175,17 +184,17 @@ export const ActivityControllerApiFp = function(configuration?: Configuration) {
async fetchNewActivitiesForCharacter(characterId: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchNewActivitiesForCharacter(characterId, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['ActivityControllerApi.fetchNewActivitiesForCharacter']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['ActivityApi.fetchNewActivitiesForCharacter']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* ActivityControllerApi - factory interface
* ActivityApi - factory interface
*/
export const ActivityControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = ActivityControllerApiFp(configuration)
export const ActivityApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = ActivityApiFp(configuration)
return {
/**
*
@@ -200,9 +209,9 @@ export const ActivityControllerApiFactory = function (configuration?: Configurat
};
/**
* ActivityControllerApi - object-oriented interface
* ActivityApi - object-oriented interface
*/
export class ActivityControllerApi extends BaseAPI {
export class ActivityApi extends BaseAPI {
/**
*
* @param {number} characterId
@@ -210,16 +219,16 @@ export class ActivityControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public fetchNewActivitiesForCharacter(characterId: number, options?: RawAxiosRequestConfig) {
return ActivityControllerApiFp(this.configuration).fetchNewActivitiesForCharacter(characterId, options).then((request) => request(this.axios, this.basePath));
return ActivityApiFp(this.configuration).fetchNewActivitiesForCharacter(characterId, options).then((request) => request(this.axios, this.basePath));
}
}
/**
* CharacterControllerApi - axios parameter creator
* CharacterApi - axios parameter creator
*/
export const CharacterControllerApiAxiosParamCreator = function (configuration?: Configuration) {
export const CharacterApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
@@ -254,10 +263,10 @@ export const CharacterControllerApiAxiosParamCreator = function (configuration?:
};
/**
* CharacterControllerApi - functional programming interface
* CharacterApi - functional programming interface
*/
export const CharacterControllerApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = CharacterControllerApiAxiosParamCreator(configuration)
export const CharacterApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = CharacterApiAxiosParamCreator(configuration)
return {
/**
*
@@ -267,17 +276,17 @@ export const CharacterControllerApiFp = function(configuration?: Configuration)
async findAllCharacters(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<CharacterResponse>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.findAllCharacters(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['CharacterControllerApi.findAllCharacters']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['CharacterApi.findAllCharacters']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* CharacterControllerApi - factory interface
* CharacterApi - factory interface
*/
export const CharacterControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = CharacterControllerApiFp(configuration)
export const CharacterApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = CharacterApiFp(configuration)
return {
/**
*
@@ -291,25 +300,194 @@ export const CharacterControllerApiFactory = function (configuration?: Configura
};
/**
* CharacterControllerApi - object-oriented interface
* CharacterApi - object-oriented interface
*/
export class CharacterControllerApi extends BaseAPI {
export class CharacterApi extends BaseAPI {
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public findAllCharacters(options?: RawAxiosRequestConfig) {
return CharacterControllerApiFp(this.configuration).findAllCharacters(options).then((request) => request(this.axios, this.basePath));
return CharacterApiFp(this.configuration).findAllCharacters(options).then((request) => request(this.axios, this.basePath));
}
}
/**
* LedgerControllerApi - axios parameter creator
* CharacterRuleBookApi - axios parameter creator
*/
export const LedgerControllerApiAxiosParamCreator = function (configuration?: Configuration) {
export const CharacterRuleBookApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @param {number} characterId
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
findCharacterRuleBookByCharacterId: async (characterId: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'characterId' is not null or undefined
assertParamExists('findCharacterRuleBookByCharacterId', 'characterId', characterId)
const localVarPath = `/characters/{characterId}/rule-book`
.replace('{characterId}', encodeURIComponent(String(characterId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarHeaderParameter['Accept'] = '*/*';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {number} characterId
* @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
setCharacterRuleBookForCharacter: async (characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'characterId' is not null or undefined
assertParamExists('setCharacterRuleBookForCharacter', 'characterId', characterId)
// verify required parameter 'setCharacterRuleBookRequest' is not null or undefined
assertParamExists('setCharacterRuleBookForCharacter', 'setCharacterRuleBookRequest', setCharacterRuleBookRequest)
const localVarPath = `/characters/{characterId}/rule-book`
.replace('{characterId}', encodeURIComponent(String(characterId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarHeaderParameter['Content-Type'] = 'application/json';
localVarHeaderParameter['Accept'] = '*/*';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(setCharacterRuleBookRequest, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};
/**
* CharacterRuleBookApi - functional programming interface
*/
export const CharacterRuleBookApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = CharacterRuleBookApiAxiosParamCreator(configuration)
return {
/**
*
* @param {number} characterId
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async findCharacterRuleBookByCharacterId(characterId: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CharacterRuleBookResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.findCharacterRuleBookByCharacterId(characterId, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['CharacterRuleBookApi.findCharacterRuleBookByCharacterId']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @param {number} characterId
* @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async setCharacterRuleBookForCharacter(characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CharacterRuleBookResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.setCharacterRuleBookForCharacter(characterId, setCharacterRuleBookRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['CharacterRuleBookApi.setCharacterRuleBookForCharacter']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* CharacterRuleBookApi - factory interface
*/
export const CharacterRuleBookApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = CharacterRuleBookApiFp(configuration)
return {
/**
*
* @param {number} characterId
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
findCharacterRuleBookByCharacterId(characterId: number, options?: RawAxiosRequestConfig): AxiosPromise<CharacterRuleBookResponse> {
return localVarFp.findCharacterRuleBookByCharacterId(characterId, options).then((request) => request(axios, basePath));
},
/**
*
* @param {number} characterId
* @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
setCharacterRuleBookForCharacter(characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options?: RawAxiosRequestConfig): AxiosPromise<CharacterRuleBookResponse> {
return localVarFp.setCharacterRuleBookForCharacter(characterId, setCharacterRuleBookRequest, options).then((request) => request(axios, basePath));
},
};
};
/**
* CharacterRuleBookApi - object-oriented interface
*/
export class CharacterRuleBookApi extends BaseAPI {
/**
*
* @param {number} characterId
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public findCharacterRuleBookByCharacterId(characterId: number, options?: RawAxiosRequestConfig) {
return CharacterRuleBookApiFp(this.configuration).findCharacterRuleBookByCharacterId(characterId, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @param {number} characterId
* @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public setCharacterRuleBookForCharacter(characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options?: RawAxiosRequestConfig) {
return CharacterRuleBookApiFp(this.configuration).setCharacterRuleBookForCharacter(characterId, setCharacterRuleBookRequest, options).then((request) => request(this.axios, this.basePath));
}
}
/**
* LedgerApi - axios parameter creator
*/
export const LedgerApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
@@ -521,10 +699,10 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co
};
/**
* LedgerControllerApi - functional programming interface
* LedgerApi - functional programming interface
*/
export const LedgerControllerApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = LedgerControllerApiAxiosParamCreator(configuration)
export const LedgerApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = LedgerApiAxiosParamCreator(configuration)
return {
/**
*
@@ -535,7 +713,7 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
async createCombinedLedger(createCombinedLedgerRequest: CreateCombinedLedgerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CombinedLedgerResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.createCombinedLedger(createCombinedLedgerRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.createCombinedLedger']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['LedgerApi.createCombinedLedger']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
@@ -547,7 +725,7 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
async createMainLedger(createMainLedgerRequest: CreateMainLedgerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<MainLedgerResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.createMainLedger(createMainLedgerRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.createMainLedger']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['LedgerApi.createMainLedger']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
@@ -558,7 +736,7 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
async findAllLedgers(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<FindAllLedgers200ResponseInner>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.findAllLedgers(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findAllLedgers']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['LedgerApi.findAllLedgers']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
@@ -570,7 +748,7 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
async findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FindAllLedgers200ResponseInner>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.findLedgerById(ledgerId, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findLedgerById']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['LedgerApi.findLedgerById']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
@@ -583,7 +761,7 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
async updateCombinedLedger(ledgerId: string, updateCombinedLedgerRequest: UpdateCombinedLedgerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CombinedLedgerResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateCombinedLedger(ledgerId, updateCombinedLedgerRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.updateCombinedLedger']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['LedgerApi.updateCombinedLedger']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
@@ -596,17 +774,17 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
async updateMainLedger(ledgerId: string, updateMainLedgerRequest: UpdateMainLedgerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<MainLedgerResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateMainLedger(ledgerId, updateMainLedgerRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.updateMainLedger']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['LedgerApi.updateMainLedger']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* LedgerControllerApi - factory interface
* LedgerApi - factory interface
*/
export const LedgerControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = LedgerControllerApiFp(configuration)
export const LedgerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = LedgerApiFp(configuration)
return {
/**
*
@@ -667,9 +845,9 @@ export const LedgerControllerApiFactory = function (configuration?: Configuratio
};
/**
* LedgerControllerApi - object-oriented interface
* LedgerApi - object-oriented interface
*/
export class LedgerControllerApi extends BaseAPI {
export class LedgerApi extends BaseAPI {
/**
*
* @param {CreateCombinedLedgerRequest} createCombinedLedgerRequest
@@ -677,7 +855,7 @@ export class LedgerControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public createCombinedLedger(createCombinedLedgerRequest: CreateCombinedLedgerRequest, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).createCombinedLedger(createCombinedLedgerRequest, options).then((request) => request(this.axios, this.basePath));
return LedgerApiFp(this.configuration).createCombinedLedger(createCombinedLedgerRequest, options).then((request) => request(this.axios, this.basePath));
}
/**
@@ -687,7 +865,7 @@ export class LedgerControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public createMainLedger(createMainLedgerRequest: CreateMainLedgerRequest, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).createMainLedger(createMainLedgerRequest, options).then((request) => request(this.axios, this.basePath));
return LedgerApiFp(this.configuration).createMainLedger(createMainLedgerRequest, options).then((request) => request(this.axios, this.basePath));
}
/**
@@ -696,7 +874,7 @@ export class LedgerControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public findAllLedgers(options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).findAllLedgers(options).then((request) => request(this.axios, this.basePath));
return LedgerApiFp(this.configuration).findAllLedgers(options).then((request) => request(this.axios, this.basePath));
}
/**
@@ -706,7 +884,7 @@ export class LedgerControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).findLedgerById(ledgerId, options).then((request) => request(this.axios, this.basePath));
return LedgerApiFp(this.configuration).findLedgerById(ledgerId, options).then((request) => request(this.axios, this.basePath));
}
/**
@@ -717,7 +895,7 @@ export class LedgerControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public updateCombinedLedger(ledgerId: string, updateCombinedLedgerRequest: UpdateCombinedLedgerRequest, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).updateCombinedLedger(ledgerId, updateCombinedLedgerRequest, options).then((request) => request(this.axios, this.basePath));
return LedgerApiFp(this.configuration).updateCombinedLedger(ledgerId, updateCombinedLedgerRequest, options).then((request) => request(this.axios, this.basePath));
}
/**
@@ -728,16 +906,16 @@ export class LedgerControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public updateMainLedger(ledgerId: string, updateMainLedgerRequest: UpdateMainLedgerRequest, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).updateMainLedger(ledgerId, updateMainLedgerRequest, options).then((request) => request(this.axios, this.basePath));
return LedgerApiFp(this.configuration).updateMainLedger(ledgerId, updateMainLedgerRequest, options).then((request) => request(this.axios, this.basePath));
}
}
/**
* ProcessingControllerApi - axios parameter creator
* ProcessingApi - axios parameter creator
*/
export const ProcessingControllerApiAxiosParamCreator = function (configuration?: Configuration) {
export const ProcessingApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
@@ -771,10 +949,10 @@ export const ProcessingControllerApiAxiosParamCreator = function (configuration?
};
/**
* ProcessingControllerApi - functional programming interface
* ProcessingApi - functional programming interface
*/
export const ProcessingControllerApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = ProcessingControllerApiAxiosParamCreator(configuration)
export const ProcessingApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = ProcessingApiAxiosParamCreator(configuration)
return {
/**
*
@@ -784,17 +962,17 @@ export const ProcessingControllerApiFp = function(configuration?: Configuration)
async processNewActivities(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.processNewActivities(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['ProcessingControllerApi.processNewActivities']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['ProcessingApi.processNewActivities']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* ProcessingControllerApi - factory interface
* ProcessingApi - factory interface
*/
export const ProcessingControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = ProcessingControllerApiFp(configuration)
export const ProcessingApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = ProcessingApiFp(configuration)
return {
/**
*
@@ -808,25 +986,25 @@ export const ProcessingControllerApiFactory = function (configuration?: Configur
};
/**
* ProcessingControllerApi - object-oriented interface
* ProcessingApi - object-oriented interface
*/
export class ProcessingControllerApi extends BaseAPI {
export class ProcessingApi extends BaseAPI {
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public processNewActivities(options?: RawAxiosRequestConfig) {
return ProcessingControllerApiFp(this.configuration).processNewActivities(options).then((request) => request(this.axios, this.basePath));
return ProcessingApiFp(this.configuration).processNewActivities(options).then((request) => request(this.axios, this.basePath));
}
}
/**
* RuleBookControllerApi - axios parameter creator
* RuleBookApi - axios parameter creator
*/
export const RuleBookControllerApiAxiosParamCreator = function (configuration?: Configuration) {
export const RuleBookApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
@@ -966,10 +1144,10 @@ export const RuleBookControllerApiAxiosParamCreator = function (configuration?:
};
/**
* RuleBookControllerApi - functional programming interface
* RuleBookApi - functional programming interface
*/
export const RuleBookControllerApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = RuleBookControllerApiAxiosParamCreator(configuration)
export const RuleBookApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = RuleBookApiAxiosParamCreator(configuration)
return {
/**
*
@@ -980,7 +1158,7 @@ export const RuleBookControllerApiFp = function(configuration?: Configuration) {
async createRuleBook(createRuleBookRequest: CreateRuleBookRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RuleBookResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.createRuleBook(createRuleBookRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.createRuleBook']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['RuleBookApi.createRuleBook']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
@@ -991,7 +1169,7 @@ export const RuleBookControllerApiFp = function(configuration?: Configuration) {
async findAllRuleBooks(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<RuleBookResponse>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.findAllRuleBooks(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.findAllRuleBooks']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['RuleBookApi.findAllRuleBooks']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
@@ -1003,7 +1181,7 @@ export const RuleBookControllerApiFp = function(configuration?: Configuration) {
async findRuleBookById(ruleBookId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RuleBookResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.findRuleBookById(ruleBookId, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.findRuleBookById']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['RuleBookApi.findRuleBookById']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
@@ -1016,17 +1194,17 @@ export const RuleBookControllerApiFp = function(configuration?: Configuration) {
async updateRuleBook(ruleBookId: string, updateRuleBookRequest: UpdateRuleBookRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RuleBookResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateRuleBook(ruleBookId, updateRuleBookRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.updateRuleBook']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['RuleBookApi.updateRuleBook']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* RuleBookControllerApi - factory interface
* RuleBookApi - factory interface
*/
export const RuleBookControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = RuleBookControllerApiFp(configuration)
export const RuleBookApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = RuleBookApiFp(configuration)
return {
/**
*
@@ -1068,9 +1246,9 @@ export const RuleBookControllerApiFactory = function (configuration?: Configurat
};
/**
* RuleBookControllerApi - object-oriented interface
* RuleBookApi - object-oriented interface
*/
export class RuleBookControllerApi extends BaseAPI {
export class RuleBookApi extends BaseAPI {
/**
*
* @param {CreateRuleBookRequest} createRuleBookRequest
@@ -1078,7 +1256,7 @@ export class RuleBookControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public createRuleBook(createRuleBookRequest: CreateRuleBookRequest, options?: RawAxiosRequestConfig) {
return RuleBookControllerApiFp(this.configuration).createRuleBook(createRuleBookRequest, options).then((request) => request(this.axios, this.basePath));
return RuleBookApiFp(this.configuration).createRuleBook(createRuleBookRequest, options).then((request) => request(this.axios, this.basePath));
}
/**
@@ -1087,7 +1265,7 @@ export class RuleBookControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public findAllRuleBooks(options?: RawAxiosRequestConfig) {
return RuleBookControllerApiFp(this.configuration).findAllRuleBooks(options).then((request) => request(this.axios, this.basePath));
return RuleBookApiFp(this.configuration).findAllRuleBooks(options).then((request) => request(this.axios, this.basePath));
}
/**
@@ -1097,7 +1275,7 @@ export class RuleBookControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public findRuleBookById(ruleBookId: string, options?: RawAxiosRequestConfig) {
return RuleBookControllerApiFp(this.configuration).findRuleBookById(ruleBookId, options).then((request) => request(this.axios, this.basePath));
return RuleBookApiFp(this.configuration).findRuleBookById(ruleBookId, options).then((request) => request(this.axios, this.basePath));
}
/**
@@ -1108,7 +1286,7 @@ export class RuleBookControllerApi extends BaseAPI {
* @throws {RequiredError}
*/
public updateRuleBook(ruleBookId: string, updateRuleBookRequest: UpdateRuleBookRequest, options?: RawAxiosRequestConfig) {
return RuleBookControllerApiFp(this.configuration).updateRuleBook(ruleBookId, updateRuleBookRequest, options).then((request) => request(this.axios, this.basePath));
return RuleBookApiFp(this.configuration).updateRuleBook(ruleBookId, updateRuleBookRequest, options).then((request) => request(this.axios, this.basePath));
}
}
+6 -6
View File
@@ -11,7 +11,7 @@ import {
} from "@/generated/mammon";
import {defineStore} from "pinia";
import {ref, triggerRef} from "vue";
import {ledgerControllerApi} from "@/mammon";
import {ledgerApi} from "@/mammon";
export const LedgerTypes = LedgerResponseTypeEnum;
@@ -59,12 +59,12 @@ export const useLedgersStore = defineStore('ledgers', () => {
const findById = (ledgerId: string): Ledger | undefined => ledgers.value.find(l => l.ledgerId === ledgerId);
const findAllById = (ledgerIds: string[]): Ledger[] => ledgerIds.map(findById).filter((x): x is Ledger => x !== undefined)
const createMain = (ledger: CreateMainLedgerRequest) => ledgerControllerApi.createMainLedger(ledger).then(response => addLedger(response.data as Ledger));
const createCombined = (ledger: CreateCombinedLedgerRequest) => ledgerControllerApi.createCombinedLedger(ledger).then(response => addLedger(response.data as Ledger));
const updateMain = (ledgerId: string, ledger: UpdateMainLedgerRequest) => ledgerControllerApi.updateMainLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger));
const updateCombined = (ledgerId: string, ledger: UpdateCombinedLedgerRequest) => ledgerControllerApi.updateCombinedLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger));
const createMain = (ledger: CreateMainLedgerRequest) => ledgerApi.createMainLedger(ledger).then(response => addLedger(response.data as Ledger));
const createCombined = (ledger: CreateCombinedLedgerRequest) => ledgerApi.createCombinedLedger(ledger).then(response => addLedger(response.data as Ledger));
const updateMain = (ledgerId: string, ledger: UpdateMainLedgerRequest) => ledgerApi.updateMainLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger));
const updateCombined = (ledgerId: string, ledger: UpdateCombinedLedgerRequest) => ledgerApi.updateCombinedLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger));
const refresh = () => ledgerControllerApi.findAllLedgers().then(response => ledgers.value = response.data as Ledger[]);
const refresh = () => ledgerApi.findAllLedgers().then(response => ledgers.value = response.data as Ledger[]);
refresh();
+12 -10
View File
@@ -1,11 +1,12 @@
import {logResource} from "@/service";
import axios from "axios";
import {
ActivityControllerApi,
CharacterControllerApi,
LedgerControllerApi,
ProcessingControllerApi,
RuleBookControllerApi
ActivityApi,
CharacterApi,
CharacterRuleBookApi,
LedgerApi,
ProcessingApi,
RuleBookApi
} from "@/generated/mammon";
export const mammonUrl = import.meta.env.VITE_MAMMON_URL;
@@ -20,8 +21,9 @@ const mammonAxiosInstance = axios.create({
})
logResource(mammonAxiosInstance)
export const ledgerControllerApi = new LedgerControllerApi(undefined, mammonUrl, mammonAxiosInstance);
export const characterControllerApi = new CharacterControllerApi(undefined, mammonUrl, mammonAxiosInstance);
export const ruleBookControllerApi = new RuleBookControllerApi(undefined, mammonUrl, mammonAxiosInstance);
export const activityControllerApi = new ActivityControllerApi(undefined, mammonUrl, mammonAxiosInstance);
export const processingControllerApi = new ProcessingControllerApi(undefined, mammonUrl, mammonAxiosInstance);
export const ledgerApi = new LedgerApi(undefined, mammonUrl, mammonAxiosInstance);
export const characterApi = new CharacterApi(undefined, mammonUrl, mammonAxiosInstance);
export const ruleBookApi = new RuleBookApi(undefined, mammonUrl, mammonAxiosInstance);
export const characterRuleBookApi = new CharacterRuleBookApi(undefined, mammonUrl, mammonAxiosInstance);
export const activityApi = new ActivityApi(undefined, mammonUrl, mammonAxiosInstance);
export const processingApi = new ProcessingApi(undefined, mammonUrl, mammonAxiosInstance);
+2 -2
View File
@@ -2,7 +2,7 @@
import {RouterView} from 'vue-router';
import {CreateLedgerModal} from "@/ledger";
import {ref} from "vue";
import {processingControllerApi} from "@/mammon";
import {processingApi} from "@/mammon";
const createLedgerModal = ref<typeof CreateLedgerModal>();
</script>
@@ -10,7 +10,7 @@ const createLedgerModal = ref<typeof CreateLedgerModal>();
<template>
<div class="mt-4">
<div class="mb-4 border-b-1 flex justify-end">
<button class="mb-2 ms-2" @click="processingControllerApi.processNewActivities()">Process Activities</button>
<button class="mb-2 ms-2" @click="processingApi.processNewActivities()">Process Activities</button>
<button class="mb-2 ms-2" @click="createLedgerModal?.open()">New Ledger</button>
</div>
<CreateLedgerModal ref="createLedgerModal" />
+95
View File
@@ -0,0 +1,95 @@
<script setup lang="ts">
import {Character, CharacterLabel, useCharactersStore} from "@/characters";
import {useRoute} from "vue-router";
import {computed, ref, watch, watchEffect} from "vue";
import log from "loglevel";
import {
findCharacterRuleBookByCharacterId,
RuleBook,
setCharacterRuleBookForCharacter,
useRuleBooksStore
} from "@/rules";
import {storeToRefs} from "pinia";
import {Ledger, LedgerSelect, systemLedger, useLedgersStore} from "@/ledger";
type Bindings = { [key: string]: Ledger; };
const ruleBookStore = useRuleBooksStore();
const {findById: findCharacterRuleBookById} = ruleBookStore;
const {ruleBooks} = storeToRefs(ruleBookStore);
const {findById: findCharacterById} = useCharactersStore();
const {ledgers} = storeToRefs(useLedgersStore());
const ledgersToUse = computed(() => [systemLedger, ...ledgers.value]);
const character = ref<Character>();
const ruleBook = ref<RuleBook>();
const bindings = ref<Bindings>({});
watchEffect(async () => {
const characterId = character.value?.characterId;
if (characterId) {
const characterRuleBook = await findCharacterRuleBookByCharacterId(characterId);
ruleBook.value = findCharacterRuleBookById(characterRuleBook.ruleBookId);
bindings.value = Object.fromEntries(
Object.entries(characterRuleBook.bindings)
.map(([key, id]) => [key, ledgersToUse.value.find(l => l.ledgerId === id) ?? systemLedger])
);
}
});
const save = () => {
const characterId = character.value?.characterId;
const ruleBookId = ruleBook.value?.ruleBookId;
if (characterId && ruleBookId) {
setCharacterRuleBookForCharacter(characterId, {
ruleBookId,
bindings: Object.fromEntries(
Object.entries(bindings.value)
.map(([key, ledger]) => [key, ledger.ledgerId])
)
})
}
}
watch(useRoute(), async route => {
if (route.params.characterId) {
const id = parseInt(typeof route.params.characterId === 'string' ? route.params.characterId : route.params.characterId[0]);
character.value = await findCharacterById(id);
log.info('Loaded character:', character.value);
} else {
character.value = undefined;
log.info('No character to load');
}
}, { immediate: true })
</script>
<template>
<div v-if="character" class="grid mb-2 mt-4">
<div class="mb-2 border-b-1 flex">
<CharacterLabel class="flex grow mb-2" :character="character" :size="64" />
<div>
<button @click="save">Save</button>
</div>
</div>
<div class="flex-col border-b-1">
Rule Book:
<select class="me-2 mb-2 w-50" v-model="ruleBook">
<option v-for="rb in ruleBooks" :key="rb.ruleBookId" :value="rb">{{ rb.name }}</option>
</select>
</div>
<div class="flex-col border-b-1">
Ledger Bindings:
<div class="flex flex-wrap items-center mb-2 mt-2">
<div class="me-2" v-for="ref in ruleBook.ledgerRefs" :ref="ref">
<span class="me-1">{{ref}}:</span>
<LedgerSelect :ledgers="ledgersToUse" :modelValue="bindings[ref] ?? systemLedger" @update:modelValue="value => bindings[ref] = value" />
</div>
</div>
</div>
</div>
</template>
+1 -1
View File
@@ -56,7 +56,7 @@ watch(useRoute(), async route => {
ruleBookId.value = id;
name.value = ruleBook?.name ?? '';
ledgerRefs.value = [...ruleBook?.ledgerRefs];
rules.value = {...ruleBook?.rules}; // todo fully clone rules
rules.value = {...ruleBook?.rules}; // TODO fully clone rules
log.info('Loaded rule book:', ruleBook);
} else {
ruleBookId.value = undefined;
+1 -1
View File
@@ -16,7 +16,7 @@ export const routes: RouteRecordRaw[] = [
{path: ':ruleBookId', name: 'edit-rule-book', component: () => import('@/pages/rules/EditRuleBook.vue')},
]},
{path: '/characters/rules', component: () => import('./pages/rules/ListCharacterRuleBooks.vue')},
{path: '/characters/:characterId/rules', name: 'character-rulebook', component: () => import('@/pages/rules/EditRuleBook.vue')},
{path: '/characters/:characterId/rules', name: 'character-rulebook', component: () => import('@/pages/rules/EditCharacterRuleBook.vue')},
]},
{path: '/market', component: () => import('@/pages/Market.vue'), children: [
+14 -7
View File
@@ -1,5 +1,12 @@
import {ledgerControllerApi, ruleBookControllerApi} from "@/mammon";
import {CreateRuleBookRequest, RuleBookResponse, RuleClauseResponseRateEnum, RuleResponse} from "@/generated/mammon";
import {characterRuleBookApi, ledgerApi, ruleBookApi} from "@/mammon";
import {
CharacterRuleBookResponse,
CreateRuleBookRequest,
RuleBookResponse,
RuleClauseResponseRateEnum,
RuleResponse,
SetCharacterRuleBookRequest
} from "@/generated/mammon";
import {defineStore} from "pinia";
import {ref, triggerRef} from "vue";
@@ -45,19 +52,19 @@ export const useRuleBooksStore = defineStore('rule-books', () => {
};
const findById = (ruleBookId: string): RuleBook | undefined => ruleBooks.value.find(rb => rb.ruleBookId === ruleBookId);
const create = (ruleBook: CreateRuleBookRequest) => ruleBookControllerApi.createRuleBook(ruleBook).then(response => addRuleBook(response.data));
const update = (ruleBookId: string, ruleBook: CreateRuleBookRequest) => ledgerControllerApi.updateMainLedger(ruleBookId, ruleBook).then(response => replaceRuleBook(response.data));
const create = (ruleBook: CreateRuleBookRequest) => ruleBookApi.createRuleBook(ruleBook).then(response => addRuleBook(response.data));
const update = (ruleBookId: string, ruleBook: CreateRuleBookRequest) => ledgerApi.updateMainLedger(ruleBookId, ruleBook).then(response => replaceRuleBook(response.data));
const refresh = () => ruleBookControllerApi.findAllRuleBooks().then(response => ruleBooks.value = response.data as RuleBook[]);
const refresh = () => ruleBookApi.findAllRuleBooks().then(response => ruleBooks.value = response.data as RuleBook[]);
refresh();
return {ruleBooks, findById, create, update, refresh};
})
export const findByCharacterId = (characterId: number): Promise<RuleBook> => ruleBookControllerApi.findById(characterId)
export const findCharacterRuleBookByCharacterId = (characterId: number): Promise<CharacterRuleBookResponse> => characterRuleBookApi.findCharacterRuleBookByCharacterId(characterId)
.then(response => response.data)
.catch(() => ({characterId, rules: {}}));
export const setCharacterRuleBook = (characterId: number, ruleBook: RuleBook): Promise<RuleBook> => ruleBookControllerApi.setCharacterRuleBook(characterId, ruleBook)
export const setCharacterRuleBookForCharacter = (characterId: number, ruleBook: SetCharacterRuleBookRequest): Promise<CharacterRuleBookResponse> => characterRuleBookApi.setCharacterRuleBookForCharacter(characterId, ruleBook)
.then(response => response.data);