rule book front
This commit is contained in:
+176
-104
@@ -6,6 +6,57 @@ servers:
|
||||
- url: http://localhost:8080
|
||||
description: Generated server url
|
||||
paths:
|
||||
/rule-books/{ruleBookId}:
|
||||
get:
|
||||
tags:
|
||||
- rule-book-controller
|
||||
operationId: findRuleBookById
|
||||
parameters:
|
||||
- name: ruleBookId
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
"404":
|
||||
description: Not Found
|
||||
"400":
|
||||
description: Bad Request
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: "#/components/schemas/RuleBookResponse"
|
||||
put:
|
||||
tags:
|
||||
- rule-book-controller
|
||||
operationId: updateRuleBook
|
||||
parameters:
|
||||
- name: ruleBookId
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/UpdateRuleBookRequest"
|
||||
required: true
|
||||
responses:
|
||||
"404":
|
||||
description: Not Found
|
||||
"400":
|
||||
description: Bad Request
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: "#/components/schemas/RuleBookResponse"
|
||||
/ledgers/main/{ledgerId}:
|
||||
put:
|
||||
tags:
|
||||
@@ -64,6 +115,45 @@ paths:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: "#/components/schemas/CombinedLedgerResponse"
|
||||
/rule-books:
|
||||
get:
|
||||
tags:
|
||||
- rule-book-controller
|
||||
operationId: findAllRuleBooks
|
||||
responses:
|
||||
"404":
|
||||
description: Not Found
|
||||
"400":
|
||||
description: Bad Request
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/RuleBookResponse"
|
||||
post:
|
||||
tags:
|
||||
- rule-book-controller
|
||||
operationId: createRuleBook
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/CreateRuleBookRequest"
|
||||
required: true
|
||||
responses:
|
||||
"404":
|
||||
description: Not Found
|
||||
"400":
|
||||
description: Bad Request
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: "#/components/schemas/RuleBookResponse"
|
||||
/process-activities:
|
||||
post:
|
||||
tags:
|
||||
@@ -120,57 +210,6 @@ paths:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: "#/components/schemas/CombinedLedgerResponse"
|
||||
/characters/{characterId}/rule-book:
|
||||
get:
|
||||
tags:
|
||||
- rule-book-controller
|
||||
operationId: findByCharacterId
|
||||
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/RuleBookResponse"
|
||||
post:
|
||||
tags:
|
||||
- rule-book-controller
|
||||
operationId: setCharacterRuleBook
|
||||
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/RuleBookResponse"
|
||||
/activity/fetch/{characterId}:
|
||||
post:
|
||||
tags:
|
||||
@@ -194,7 +233,7 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- ledger-controller
|
||||
operationId: findAll
|
||||
operationId: findAllLedgers
|
||||
responses:
|
||||
"404":
|
||||
description: Not Found
|
||||
@@ -214,7 +253,7 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- ledger-controller
|
||||
operationId: findById
|
||||
operationId: findLedgerById
|
||||
parameters:
|
||||
- name: ledgerId
|
||||
in: path
|
||||
@@ -239,7 +278,7 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- character-controller
|
||||
operationId: getCharacters
|
||||
operationId: findAllCharacters
|
||||
responses:
|
||||
"404":
|
||||
description: Not Found
|
||||
@@ -255,6 +294,72 @@ paths:
|
||||
$ref: "#/components/schemas/CharacterResponse"
|
||||
components:
|
||||
schemas:
|
||||
RuleClauseResponse:
|
||||
type: object
|
||||
properties:
|
||||
rate:
|
||||
type: string
|
||||
enum:
|
||||
- NONE
|
||||
- VALUE
|
||||
- JITA_BUY
|
||||
- JITA_SELL
|
||||
- EVE_ESTIMATE
|
||||
fromLedgerRef:
|
||||
type: string
|
||||
toLedgerRef:
|
||||
type: string
|
||||
required:
|
||||
- fromLedgerRef
|
||||
- rate
|
||||
- toLedgerRef
|
||||
RuleResponse:
|
||||
type: object
|
||||
properties:
|
||||
rules:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/RuleClauseResponse"
|
||||
required:
|
||||
- rules
|
||||
UpdateRuleBookRequest:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
ledgerRefs:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
rules:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: "#/components/schemas/RuleResponse"
|
||||
required:
|
||||
- ledgerRefs
|
||||
- name
|
||||
- rules
|
||||
RuleBookResponse:
|
||||
type: object
|
||||
properties:
|
||||
ruleBookId:
|
||||
type: string
|
||||
format: uuid
|
||||
name:
|
||||
type: string
|
||||
ledgerRefs:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
rules:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: "#/components/schemas/RuleResponse"
|
||||
required:
|
||||
- ledgerRefs
|
||||
- name
|
||||
- ruleBookId
|
||||
- rules
|
||||
UpdateMainLedgerRequest:
|
||||
type: object
|
||||
properties:
|
||||
@@ -321,6 +426,23 @@ components:
|
||||
- ledgerId
|
||||
- memberLedgerIds
|
||||
- name
|
||||
CreateRuleBookRequest:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
ledgerRefs:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
rules:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: "#/components/schemas/RuleResponse"
|
||||
required:
|
||||
- ledgerRefs
|
||||
- name
|
||||
- rules
|
||||
CreateMainLedgerRequest:
|
||||
type: object
|
||||
properties:
|
||||
@@ -341,56 +463,6 @@ components:
|
||||
required:
|
||||
- memberLedgerIds
|
||||
- name
|
||||
RuleResponse:
|
||||
type: object
|
||||
properties:
|
||||
rate:
|
||||
type: string
|
||||
enum:
|
||||
- NONE
|
||||
- VALUE
|
||||
- JITA_BUY
|
||||
- JITA_SELL
|
||||
- EVE_ESTIMATE
|
||||
fromLedgerId:
|
||||
type: string
|
||||
format: uuid
|
||||
toLedgerId:
|
||||
type: string
|
||||
format: uuid
|
||||
required:
|
||||
- rate
|
||||
RuleSetResponse:
|
||||
type: object
|
||||
properties:
|
||||
rules:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/RuleResponse"
|
||||
required:
|
||||
- rules
|
||||
SetCharacterRuleBookRequest:
|
||||
type: object
|
||||
properties:
|
||||
ruleSets:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: "#/components/schemas/RuleSetResponse"
|
||||
required:
|
||||
- ruleSets
|
||||
RuleBookResponse:
|
||||
type: object
|
||||
properties:
|
||||
characterId:
|
||||
type: integer
|
||||
format: int64
|
||||
ruleSets:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: "#/components/schemas/RuleSetResponse"
|
||||
required:
|
||||
- characterId
|
||||
- ruleSets
|
||||
LedgerResponse:
|
||||
type: object
|
||||
discriminator:
|
||||
|
||||
@@ -20,7 +20,7 @@ export const useCharactersStore = defineStore('characters', () => {
|
||||
|
||||
const reloadActivities = (characterId: number): Promise<void> => activityControllerApi.fetchNewActivitiesForCharacter(characterId) as Promise<void>;
|
||||
|
||||
const refresh = () => characterControllerApi.getCharacters().then(response => characters.value = response.data);
|
||||
const refresh = () => characterControllerApi.findAllCharacters().then(response => characters.value = response.data);
|
||||
|
||||
refresh();
|
||||
|
||||
|
||||
+204
-73
@@ -48,10 +48,15 @@ export interface CreateCombinedLedgerRequest {
|
||||
export interface CreateMainLedgerRequest {
|
||||
'name': string;
|
||||
}
|
||||
export interface CreateRuleBookRequest {
|
||||
'name': string;
|
||||
'ledgerRefs': Array<string>;
|
||||
'rules': { [key: string]: RuleResponse; };
|
||||
}
|
||||
/**
|
||||
* @type FindAll200ResponseInner
|
||||
* @type FindAllLedgers200ResponseInner
|
||||
*/
|
||||
export type FindAll200ResponseInner = CombinedLedgerResponse | MainLedgerResponse;
|
||||
export type FindAllLedgers200ResponseInner = CombinedLedgerResponse | MainLedgerResponse;
|
||||
|
||||
export interface LedgerResponse {
|
||||
'type'?: LedgerResponseTypeEnum;
|
||||
@@ -78,13 +83,15 @@ export const MainLedgerResponseTypeEnum = {
|
||||
export type MainLedgerResponseTypeEnum = typeof MainLedgerResponseTypeEnum[keyof typeof MainLedgerResponseTypeEnum];
|
||||
|
||||
export interface RuleBookResponse {
|
||||
'characterId': number;
|
||||
'ruleBookId': string;
|
||||
'name': string;
|
||||
'ledgerRefs': Array<string>;
|
||||
'rules': { [key: string]: RuleResponse; };
|
||||
}
|
||||
export interface RuleClauseResponse {
|
||||
'rate': RuleClauseResponseRateEnum;
|
||||
'fromLedgerId'?: string;
|
||||
'toLedgerId'?: string;
|
||||
'fromLedgerRef': string;
|
||||
'toLedgerRef': string;
|
||||
}
|
||||
|
||||
export const RuleClauseResponseRateEnum = {
|
||||
@@ -100,9 +107,6 @@ export type RuleClauseResponseRateEnum = typeof RuleClauseResponseRateEnum[keyof
|
||||
export interface RuleResponse {
|
||||
'rules': Array<RuleClauseResponse>;
|
||||
}
|
||||
export interface SetCharacterRuleBookRequest {
|
||||
'rules': { [key: string]: RuleResponse; };
|
||||
}
|
||||
export interface UpdateCombinedLedgerRequest {
|
||||
'name': string;
|
||||
'memberLedgerIds': Array<string>;
|
||||
@@ -110,6 +114,11 @@ export interface UpdateCombinedLedgerRequest {
|
||||
export interface UpdateMainLedgerRequest {
|
||||
'name': string;
|
||||
}
|
||||
export interface UpdateRuleBookRequest {
|
||||
'name': string;
|
||||
'ledgerRefs': Array<string>;
|
||||
'rules': { [key: string]: RuleResponse; };
|
||||
}
|
||||
|
||||
/**
|
||||
* ActivityControllerApi - axios parameter creator
|
||||
@@ -217,7 +226,7 @@ export const CharacterControllerApiAxiosParamCreator = function (configuration?:
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getCharacters: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
findAllCharacters: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
const localVarPath = `/characters`;
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
@@ -255,10 +264,10 @@ export const CharacterControllerApiFp = function(configuration?: Configuration)
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async getCharacters(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<CharacterResponse>>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getCharacters(options);
|
||||
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.getCharacters']?.[localVarOperationServerIndex]?.url;
|
||||
const localVarOperationServerBasePath = operationServerMap['CharacterControllerApi.findAllCharacters']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
}
|
||||
@@ -275,8 +284,8 @@ export const CharacterControllerApiFactory = function (configuration?: Configura
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getCharacters(options?: RawAxiosRequestConfig): AxiosPromise<Array<CharacterResponse>> {
|
||||
return localVarFp.getCharacters(options).then((request) => request(axios, basePath));
|
||||
findAllCharacters(options?: RawAxiosRequestConfig): AxiosPromise<Array<CharacterResponse>> {
|
||||
return localVarFp.findAllCharacters(options).then((request) => request(axios, basePath));
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -290,8 +299,8 @@ export class CharacterControllerApi extends BaseAPI {
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
public getCharacters(options?: RawAxiosRequestConfig) {
|
||||
return CharacterControllerApiFp(this.configuration).getCharacters(options).then((request) => request(this.axios, this.basePath));
|
||||
public findAllCharacters(options?: RawAxiosRequestConfig) {
|
||||
return CharacterControllerApiFp(this.configuration).findAllCharacters(options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +384,7 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
findAll: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
findAllLedgers: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
const localVarPath = `/ledgers`;
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
@@ -405,9 +414,9 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
findById: async (ledgerId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
findLedgerById: async (ledgerId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'ledgerId' is not null or undefined
|
||||
assertParamExists('findById', 'ledgerId', ledgerId)
|
||||
assertParamExists('findLedgerById', 'ledgerId', ledgerId)
|
||||
const localVarPath = `/ledgers/{ledgerId}`
|
||||
.replace('{ledgerId}', encodeURIComponent(String(ledgerId)));
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
@@ -546,10 +555,10 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async findAll(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<FindAll200ResponseInner>>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
|
||||
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.findAll']?.[localVarOperationServerIndex]?.url;
|
||||
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findAllLedgers']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
@@ -558,10 +567,10 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async findById(ledgerId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FindAll200ResponseInner>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.findById(ledgerId, options);
|
||||
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.findById']?.[localVarOperationServerIndex]?.url;
|
||||
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findLedgerById']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
@@ -622,8 +631,8 @@ export const LedgerControllerApiFactory = function (configuration?: Configuratio
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
findAll(options?: RawAxiosRequestConfig): AxiosPromise<Array<FindAll200ResponseInner>> {
|
||||
return localVarFp.findAll(options).then((request) => request(axios, basePath));
|
||||
findAllLedgers(options?: RawAxiosRequestConfig): AxiosPromise<Array<FindAllLedgers200ResponseInner>> {
|
||||
return localVarFp.findAllLedgers(options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
@@ -631,8 +640,8 @@ export const LedgerControllerApiFactory = function (configuration?: Configuratio
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
findById(ledgerId: string, options?: RawAxiosRequestConfig): AxiosPromise<FindAll200ResponseInner> {
|
||||
return localVarFp.findById(ledgerId, options).then((request) => request(axios, basePath));
|
||||
findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig): AxiosPromise<FindAllLedgers200ResponseInner> {
|
||||
return localVarFp.findLedgerById(ledgerId, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
@@ -686,8 +695,8 @@ export class LedgerControllerApi extends BaseAPI {
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
public findAll(options?: RawAxiosRequestConfig) {
|
||||
return LedgerControllerApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
|
||||
public findAllLedgers(options?: RawAxiosRequestConfig) {
|
||||
return LedgerControllerApiFp(this.configuration).findAllLedgers(options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -696,8 +705,8 @@ export class LedgerControllerApi extends BaseAPI {
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
public findById(ledgerId: string, options?: RawAxiosRequestConfig) {
|
||||
return LedgerControllerApiFp(this.configuration).findById(ledgerId, options).then((request) => request(this.axios, this.basePath));
|
||||
public findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig) {
|
||||
return LedgerControllerApiFp(this.configuration).findLedgerById(ledgerId, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -821,15 +830,45 @@ export const RuleBookControllerApiAxiosParamCreator = function (configuration?:
|
||||
return {
|
||||
/**
|
||||
*
|
||||
* @param {number} characterId
|
||||
* @param {CreateRuleBookRequest} createRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
findByCharacterId: async (characterId: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'characterId' is not null or undefined
|
||||
assertParamExists('findByCharacterId', 'characterId', characterId)
|
||||
const localVarPath = `/characters/{characterId}/rule-book`
|
||||
.replace('{characterId}', encodeURIComponent(String(characterId)));
|
||||
createRuleBook: async (createRuleBookRequest: CreateRuleBookRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'createRuleBookRequest' is not null or undefined
|
||||
assertParamExists('createRuleBook', 'createRuleBookRequest', createRuleBookRequest)
|
||||
const localVarPath = `/rule-books`;
|
||||
// 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: 'POST', ...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(createRuleBookRequest, localVarRequestOptions, configuration)
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
findAllRuleBooks: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
const localVarPath = `/rule-books`;
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
@@ -854,18 +893,15 @@ export const RuleBookControllerApiAxiosParamCreator = function (configuration?:
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {number} characterId
|
||||
* @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest
|
||||
* @param {string} ruleBookId
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
setCharacterRuleBook: async (characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'characterId' is not null or undefined
|
||||
assertParamExists('setCharacterRuleBook', 'characterId', characterId)
|
||||
// verify required parameter 'setCharacterRuleBookRequest' is not null or undefined
|
||||
assertParamExists('setCharacterRuleBook', 'setCharacterRuleBookRequest', setCharacterRuleBookRequest)
|
||||
const localVarPath = `/characters/{characterId}/rule-book`
|
||||
.replace('{characterId}', encodeURIComponent(String(characterId)));
|
||||
findRuleBookById: async (ruleBookId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'ruleBookId' is not null or undefined
|
||||
assertParamExists('findRuleBookById', 'ruleBookId', ruleBookId)
|
||||
const localVarPath = `/rule-books/{ruleBookId}`
|
||||
.replace('{ruleBookId}', encodeURIComponent(String(ruleBookId)));
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
@@ -873,7 +909,43 @@ export const RuleBookControllerApiAxiosParamCreator = function (configuration?:
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
|
||||
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
|
||||
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 {string} ruleBookId
|
||||
* @param {UpdateRuleBookRequest} updateRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updateRuleBook: async (ruleBookId: string, updateRuleBookRequest: UpdateRuleBookRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'ruleBookId' is not null or undefined
|
||||
assertParamExists('updateRuleBook', 'ruleBookId', ruleBookId)
|
||||
// verify required parameter 'updateRuleBookRequest' is not null or undefined
|
||||
assertParamExists('updateRuleBook', 'updateRuleBookRequest', updateRuleBookRequest)
|
||||
const localVarPath = `/rule-books/{ruleBookId}`
|
||||
.replace('{ruleBookId}', encodeURIComponent(String(ruleBookId)));
|
||||
// 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;
|
||||
|
||||
@@ -883,7 +955,7 @@ export const RuleBookControllerApiAxiosParamCreator = function (configuration?:
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
localVarRequestOptions.data = serializeDataIfNeeded(setCharacterRuleBookRequest, localVarRequestOptions, configuration)
|
||||
localVarRequestOptions.data = serializeDataIfNeeded(updateRuleBookRequest, localVarRequestOptions, configuration)
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
@@ -901,27 +973,50 @@ export const RuleBookControllerApiFp = function(configuration?: Configuration) {
|
||||
return {
|
||||
/**
|
||||
*
|
||||
* @param {number} characterId
|
||||
* @param {CreateRuleBookRequest} createRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async findByCharacterId(characterId: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RuleBookResponse>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.findByCharacterId(characterId, options);
|
||||
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.findByCharacterId']?.[localVarOperationServerIndex]?.url;
|
||||
const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.createRuleBook']?.[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 setCharacterRuleBook(characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RuleBookResponse>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.setCharacterRuleBook(characterId, setCharacterRuleBookRequest, options);
|
||||
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.setCharacterRuleBook']?.[localVarOperationServerIndex]?.url;
|
||||
const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.findAllRuleBooks']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {string} ruleBookId
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
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;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {string} ruleBookId
|
||||
* @param {UpdateRuleBookRequest} updateRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
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;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
}
|
||||
@@ -935,22 +1030,39 @@ export const RuleBookControllerApiFactory = function (configuration?: Configurat
|
||||
return {
|
||||
/**
|
||||
*
|
||||
* @param {number} characterId
|
||||
* @param {CreateRuleBookRequest} createRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
findByCharacterId(characterId: number, options?: RawAxiosRequestConfig): AxiosPromise<RuleBookResponse> {
|
||||
return localVarFp.findByCharacterId(characterId, options).then((request) => request(axios, basePath));
|
||||
createRuleBook(createRuleBookRequest: CreateRuleBookRequest, options?: RawAxiosRequestConfig): AxiosPromise<RuleBookResponse> {
|
||||
return localVarFp.createRuleBook(createRuleBookRequest, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {number} characterId
|
||||
* @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
setCharacterRuleBook(characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options?: RawAxiosRequestConfig): AxiosPromise<RuleBookResponse> {
|
||||
return localVarFp.setCharacterRuleBook(characterId, setCharacterRuleBookRequest, options).then((request) => request(axios, basePath));
|
||||
findAllRuleBooks(options?: RawAxiosRequestConfig): AxiosPromise<Array<RuleBookResponse>> {
|
||||
return localVarFp.findAllRuleBooks(options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {string} ruleBookId
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
findRuleBookById(ruleBookId: string, options?: RawAxiosRequestConfig): AxiosPromise<RuleBookResponse> {
|
||||
return localVarFp.findRuleBookById(ruleBookId, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {string} ruleBookId
|
||||
* @param {UpdateRuleBookRequest} updateRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updateRuleBook(ruleBookId: string, updateRuleBookRequest: UpdateRuleBookRequest, options?: RawAxiosRequestConfig): AxiosPromise<RuleBookResponse> {
|
||||
return localVarFp.updateRuleBook(ruleBookId, updateRuleBookRequest, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -961,23 +1073,42 @@ export const RuleBookControllerApiFactory = function (configuration?: Configurat
|
||||
export class RuleBookControllerApi extends BaseAPI {
|
||||
/**
|
||||
*
|
||||
* @param {number} characterId
|
||||
* @param {CreateRuleBookRequest} createRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
public findByCharacterId(characterId: number, options?: RawAxiosRequestConfig) {
|
||||
return RuleBookControllerApiFp(this.configuration).findByCharacterId(characterId, options).then((request) => request(this.axios, this.basePath));
|
||||
public createRuleBook(createRuleBookRequest: CreateRuleBookRequest, options?: RawAxiosRequestConfig) {
|
||||
return RuleBookControllerApiFp(this.configuration).createRuleBook(createRuleBookRequest, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {number} characterId
|
||||
* @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
public setCharacterRuleBook(characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options?: RawAxiosRequestConfig) {
|
||||
return RuleBookControllerApiFp(this.configuration).setCharacterRuleBook(characterId, setCharacterRuleBookRequest, options).then((request) => request(this.axios, this.basePath));
|
||||
public findAllRuleBooks(options?: RawAxiosRequestConfig) {
|
||||
return RuleBookControllerApiFp(this.configuration).findAllRuleBooks(options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} ruleBookId
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
public findRuleBookById(ruleBookId: string, options?: RawAxiosRequestConfig) {
|
||||
return RuleBookControllerApiFp(this.configuration).findRuleBookById(ruleBookId, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} ruleBookId
|
||||
* @param {UpdateRuleBookRequest} updateRuleBookRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ export type MainLedger = MainLedgerResponse & {type: MainLedgerResponseTypeEnum}
|
||||
export type CombinedLedger = CombinedLedgerResponse & {type: CombinedLedgerResponseTypeEnum}
|
||||
export type Ledger = MainLedger | CombinedLedger;
|
||||
|
||||
|
||||
export const systemLedgerRef = 'system';
|
||||
export const systemLedger = {
|
||||
type: LedgerTypes.Main,
|
||||
ledgerId: "",
|
||||
@@ -62,7 +64,7 @@ export const useLedgersStore = defineStore('ledgers', () => {
|
||||
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 refresh = () => ledgerControllerApi.findAll().then(response => ledgers.value = response.data as Ledger[]);
|
||||
const refresh = () => ledgerControllerApi.findAllLedgers().then(response => ledgers.value = response.data as Ledger[]);
|
||||
|
||||
refresh();
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import {RouterLink, RouterView} from 'vue-router';
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -19,14 +18,3 @@ import { RouterLink, RouterView } from 'vue-router';
|
||||
<RouterView />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "tailwindcss";
|
||||
|
||||
a.tab {
|
||||
@apply flex items-center px-4 me-2 rounded-t-md bg-slate-600 hover:bg-slate-700;
|
||||
&.router-link-active {
|
||||
@apply bg-emerald-500 hover:bg-emerald-700;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import {RouterLink, RouterView} from "vue-router";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mt-4">
|
||||
<div class="flex border-b-2 border-emerald-500">
|
||||
<RouterLink :to="{ name: 'list-rule-books' }" class="tab">
|
||||
<span>Rule Books</span>
|
||||
</RouterLink>
|
||||
<RouterLink to="/characters/rules" class="tab">
|
||||
<span>Characters Rules</span>
|
||||
</RouterLink>
|
||||
</div>
|
||||
<RouterView />
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,57 +1,101 @@
|
||||
<script setup lang="ts">
|
||||
import {Character, CharacterLabel, useCharactersStore} from "@/characters";
|
||||
import {useRoute} from "vue-router";
|
||||
import {ref, watch, watchEffect} from "vue";
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
import {ref, watch} from "vue";
|
||||
import {useDebounceFn} from "@vueuse/core";
|
||||
import log from "loglevel";
|
||||
import {activityTypes, findByCharacterId, RuleBook, RuleInput, setCharacterRuleBook} from "@/rules";
|
||||
import {activityTypes, RuleInput, Rules, useRuleBooksStore} from "@/rules";
|
||||
import {PlusIcon, TrashIcon} from "@heroicons/vue/24/outline";
|
||||
|
||||
const {findById: findCharacterById} = useCharactersStore();
|
||||
const character = ref<Character>();
|
||||
const ruleBookId = ref<string>();
|
||||
const name = ref<string>('');
|
||||
const ledgerRefs = ref<string[]>([]);
|
||||
const rules = ref<Rules>({});
|
||||
|
||||
const ruleBook = ref<RuleBook>();
|
||||
const {findById, create, update, refresh} = useRuleBooksStore();
|
||||
const router = useRouter();
|
||||
|
||||
watchEffect(async () => {
|
||||
const characterId = character.value?.characterId;
|
||||
const save = async () => {
|
||||
if (!ruleBookId.value) {
|
||||
const created = await create({
|
||||
name: name.value,
|
||||
ledgerRefs: ledgerRefs.value,
|
||||
rules: rules.value
|
||||
})
|
||||
await router.push({ name: 'edit-rule-book', params: {ruleBookId: created.ruleBookId}})
|
||||
|
||||
if (characterId) {
|
||||
ruleBook.value = await findByCharacterId(characterId);
|
||||
} else {
|
||||
await update(ruleBookId.value, {
|
||||
name: name.value,
|
||||
ledgerRefs: ledgerRefs.value,
|
||||
rules: rules.value
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
const save = () => {
|
||||
const characterId = character.value?.characterId;
|
||||
|
||||
if (characterId && ruleBook.value) {
|
||||
setCharacterRuleBook(characterId, ruleBook.value);
|
||||
}
|
||||
|
||||
const addLedgerRef = () => {
|
||||
ledgerRefs.value = [...ledgerRefs.value, '']
|
||||
}
|
||||
const updateLedgerRef = useDebounceFn((index: number, value: string) => {
|
||||
ledgerRefs.value[index] = value;
|
||||
}, 500);
|
||||
|
||||
const removeLedgerRef = (index: number) => {
|
||||
ledgerRefs.value = ledgerRefs.value.toSpliced(index, 1)
|
||||
}
|
||||
|
||||
watch(useRoute(), async route => {
|
||||
if (route.params.characterId) {
|
||||
const id = parseInt(typeof route.params.characterId === 'string' ? route.params.characterId : route.params.characterId[0]);
|
||||
if (route.params.ruleBookId) {
|
||||
const promise = refresh(); // FIXME don't call refresh
|
||||
|
||||
character.value = await findCharacterById(id);
|
||||
log.info('Loaded character:', character.value);
|
||||
const id = typeof route.params.ruleBookId === 'string' ? route.params.ruleBookId : route.params.ruleBookId[0];
|
||||
|
||||
await promise;
|
||||
|
||||
const ruleBook = findById(id);
|
||||
|
||||
ruleBookId.value = id;
|
||||
name.value = ruleBook?.name ?? '';
|
||||
ledgerRefs.value = [...ruleBook?.ledgerRefs];
|
||||
rules.value = {...ruleBook?.rules}; // todo fully clone rules
|
||||
log.info('Loaded rule book:', ruleBook);
|
||||
} else {
|
||||
character.value = undefined;
|
||||
log.info('No character to load');
|
||||
ruleBookId.value = undefined;
|
||||
name.value = '';
|
||||
ledgerRefs.value = [];
|
||||
rules.value = {};
|
||||
log.info('No rule book 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 class="grid mb-2 mt-4">
|
||||
<div class="flex flex-col">
|
||||
<div class="flex grow border-b-1">
|
||||
Name:
|
||||
<input class="mb-2 ms-2" type="text" v-model="name" />
|
||||
</div>
|
||||
<div class="border-b-1">
|
||||
Ledgers References:
|
||||
<div class="flex flex-wrap items-center">
|
||||
<div class="flex items-center mb-2" v-for="(ledgerRef, index) in ledgerRefs" :key="index">
|
||||
<input class="me-1" type="text" :value="ledgerRefs[index]" @input="updateLedgerRef(index, ($event.target as HTMLInputElement).value)" />
|
||||
<button class="btn-icon me-2" @click="addLedgerRef"><TrashIcon /></button>
|
||||
</div>
|
||||
<div class="flex items-center mb-2">
|
||||
<button class="btn-icon" @click="removeLedgerRef(index)"><PlusIcon /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col grow border-b-1" v-for="activityType in activityTypes" :key="activityType.key">
|
||||
<span>{{ activityType.name }}</span>
|
||||
<RuleInput :ledgerRefs="ledgerRefs" v-model="rules[activityType.key]" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 justify-end flex">
|
||||
<div>
|
||||
<button @click="save">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="ruleBook" class="flex-col">
|
||||
<div class="flex-col grow border-b-1" v-for="activityType in activityTypes" :key="activityType.key">
|
||||
<span>{{ activityType.name }}</span>
|
||||
<RuleInput v-model="ruleBook.rules[activityType.key]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import {storeToRefs} from "pinia";
|
||||
import {CharacterLabel, useCharactersStore} from "@/characters";
|
||||
import {PencilSquareIcon} from "@heroicons/vue/24/outline";
|
||||
|
||||
const {characters} = storeToRefs(useCharactersStore());
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid mb-2 mt-4">
|
||||
<div v-for="character in characters" :key="character.characterId" class="flex items-center mb-2">
|
||||
<CharacterLabel class="flex grow" :character="character" />
|
||||
<RouterLink class="btn-icon ms-2" :to="{ name: 'character-rulebook', params: { characterId: character.characterId } }"><PencilSquareIcon /></RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,17 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import {storeToRefs} from "pinia";
|
||||
import {CharacterLabel, useCharactersStore} from "@/characters";
|
||||
import {PencilSquareIcon} from "@heroicons/vue/24/outline";
|
||||
import {PencilSquareIcon, TrashIcon} from "@heroicons/vue/24/outline";
|
||||
import {useRuleBooksStore} from "@/rules";
|
||||
|
||||
const {characters} = storeToRefs(useCharactersStore());
|
||||
const {ruleBooks} = storeToRefs(useRuleBooksStore());
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid mb-2 mt-4">
|
||||
<div v-for="character in characters" :key="character.characterId" class="flex items-center mb-2">
|
||||
<CharacterLabel class="flex grow" :character="character" />
|
||||
<RouterLink class="btn-icon ms-2" :to="{ name: 'character-rulebook', params: { characterId: character.characterId } }"><PencilSquareIcon /></RouterLink>
|
||||
<div class="flex justify-end border-b-1">
|
||||
<RouterLink class="button mb-2 ms-2" :to="{ name: 'new-rule-book'}">New Rule Book</RouterLink>
|
||||
</div>
|
||||
<div v-for="ruleBook in ruleBooks" :key="ruleBook.ruleBookId" class="flex items-center mt-2">
|
||||
<span class="flex grow me-2">{{ruleBook.name}}</span>
|
||||
<RouterLink class="btn-icon me-1" :to="{ name: 'edit-rule-book', params: { ruleBookId: ruleBook.ruleBookId } }"><PencilSquareIcon /></RouterLink>
|
||||
<button class="btn-icon"><TrashIcon /></button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+8
-2
@@ -9,8 +9,14 @@ export const routes: RouteRecordRaw[] = [
|
||||
]},
|
||||
|
||||
{path: '/rules', component: () => import('@/pages/Rules.vue'), children: [
|
||||
{path: '', component: () => import('./pages/rules/ListRuleBooks.vue')},
|
||||
{path: '/characters/:characterId/rule-book', name: 'character-rulebook', component: () => import('@/pages/rules/EditRuleBook.vue')},
|
||||
{path: '', redirect: '/rule-books'},
|
||||
{path: '/rule-books', children: [
|
||||
{path: '', name: 'list-rule-books', component: () => import('./pages/rules/ListRuleBooks.vue')},
|
||||
{path: 'new', name: 'new-rule-book', component: () => import('@/pages/rules/EditRuleBook.vue')},
|
||||
{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: '/market', component: () => import('@/pages/Market.vue'), children: [
|
||||
|
||||
@@ -1,37 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import {RuleClauseResponse} from "@/generated/mammon";
|
||||
import {computed} from "vue";
|
||||
import {isMain, Ledger, LedgerSelect, systemLedger, useLedgersStore} from "@/ledger";
|
||||
import {computed, watch} from "vue";
|
||||
import {systemLedgerRef} from "@/ledger";
|
||||
import {ratesTypes} from "@/rules/rules.ts";
|
||||
|
||||
const rule = defineModel<RuleClauseResponse>();
|
||||
|
||||
const ledgersStore = useLedgersStore();
|
||||
const {findById} = ledgersStore;
|
||||
const ledgers = computed<Ledger[]>(() => [systemLedger, ...ledgersStore.ledgers.filter(isMain)]);
|
||||
|
||||
const ledgerComputed = (key: 'fromLedgerId' | 'toLedgerId') => computed<Ledger>({
|
||||
get: () => rule.value && rule.value[key] ? findById(rule.value[key]) ?? systemLedger : systemLedger,
|
||||
set: value => {
|
||||
if (value) {
|
||||
rule.value = {...rule.value, [key]: value.ledgerId.length ? value.ledgerId : undefined}
|
||||
interface Props {
|
||||
ledgerRefs: string[];
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const rule = defineModel<RuleClauseResponse>({ default: {
|
||||
rate: ratesTypes.None,
|
||||
fromLedgerRef: systemLedgerRef,
|
||||
toLedgerRef: systemLedgerRef,
|
||||
}});
|
||||
|
||||
const ledgerRefsWithSystem = computed<string[]>(() => [systemLedgerRef, ...props.ledgerRefs])
|
||||
|
||||
watch(ledgerRefsWithSystem, (newVal, oldVal) => {
|
||||
if (newVal.length !== oldVal.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rule.value.fromLedgerRef && rule.value.fromLedgerRef !== systemLedgerRef) {
|
||||
rule.value.fromLedgerRef = newVal[oldVal.findIndex(v => v === rule.value.fromLedgerRef)]
|
||||
}
|
||||
if (rule.value.toLedgerRef && rule.value.toLedgerRef !== systemLedgerRef) {
|
||||
rule.value.toLedgerRef = newVal[oldVal.findIndex(v => v === rule.value.toLedgerRef)]
|
||||
}
|
||||
})
|
||||
|
||||
const fromLedger = ledgerComputed('fromLedgerId')
|
||||
const toLedger = ledgerComputed('toLedgerId')
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
From:
|
||||
<LedgerSelect class="me-2 grow" v-model="fromLedger" :ledgers="ledgers" />
|
||||
<select class="me-2 grow" v-model="rule.fromLedgerRef" :class="{'system-ledger': rule.fromLedgerRef === systemLedgerRef}">
|
||||
<option v-for="l in ledgerRefsWithSystem" :key="l" :value="l" :class="{'system-ledger': l === systemLedgerRef}">{{ l }}</option>
|
||||
</select>
|
||||
To:
|
||||
<LedgerSelect class="me-2 grow" v-model="toLedger" :ledgers="ledgers" />
|
||||
<select class="me-2 grow" v-model="rule.toLedgerRef" :class="{'system-ledger': rule.toLedgerRef === systemLedgerRef}">
|
||||
<option v-for="l in ledgerRefsWithSystem" :key="l" :value="l" :class="{'system-ledger': l === systemLedgerRef}">{{ l }}</option>
|
||||
</select>
|
||||
At:
|
||||
<select class="me-2 grow" v-model="rule.rate">
|
||||
<option v-for="rateType in ratesTypes" :key="rateType.key" :value="rateType.key">{{ rateType.name }}</option>
|
||||
</select>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "tailwindcss";
|
||||
|
||||
.system-ledger {
|
||||
@apply text-emerald-400;
|
||||
}
|
||||
</style>
|
||||
@@ -6,7 +6,13 @@ import {computed, useTemplateRef} from "vue";
|
||||
import {Bars4Icon, PlusIcon, TrashIcon} from '@heroicons/vue/24/outline';
|
||||
import {useSortable} from "@vueuse/integrations/useSortable";
|
||||
|
||||
const rule = defineModel<RuleResponse>();
|
||||
interface Props {
|
||||
ledgerRefs: string[];
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const rule = defineModel<RuleResponse>({default: {rules:{}}});
|
||||
const rules = computed<RuleClauseResponse[]>({
|
||||
get: () => rule.value && rule.value.rules ? rule.value.rules : [],
|
||||
set: value => rule.value = {rules: value}
|
||||
@@ -38,7 +44,7 @@ useSortable(sortableContainer, rules, { handle: '.sortable-handle'});
|
||||
<span class="sortable-handle flex">
|
||||
<Bars4Icon class="w-6"/>
|
||||
</span>
|
||||
<RuleClauseInput :modelValue="rule" @update:modelValue="v => setRule(index, v)" />
|
||||
<RuleClauseInput :ledgerRefs="ledgerRefs" :modelValue="rule" @update:modelValue="v => setRule(index, v)" />
|
||||
<button class="btn-icon" @click="removeRule(index)"><TrashIcon /></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+37
-4
@@ -1,5 +1,7 @@
|
||||
import {ruleBookControllerApi} from "@/mammon";
|
||||
import {RuleBookResponse, RuleClauseResponseRateEnum, RuleResponse} from "@/generated/mammon";
|
||||
import {ledgerControllerApi, ruleBookControllerApi} from "@/mammon";
|
||||
import {CreateRuleBookRequest, RuleBookResponse, RuleClauseResponseRateEnum, RuleResponse} from "@/generated/mammon";
|
||||
import {defineStore} from "pinia";
|
||||
import {ref, triggerRef} from "vue";
|
||||
|
||||
export const activityTypes = {
|
||||
itemBought: {key: "ITEM_BOUGHT", name: "Item Bought"},
|
||||
@@ -10,7 +12,8 @@ export const activityTypes = {
|
||||
|
||||
export type Activity = { key: ActivityType, name: string }
|
||||
export type ActivityType = typeof activityTypes[keyof typeof activityTypes]['key'];
|
||||
export type RuleBook = RuleBookResponse & { rules: { [key: ActivityType]: RuleResponse; } }
|
||||
export type Rules = { [key: ActivityType]: RuleResponse; };
|
||||
export type RuleBook = RuleBookResponse & { rules: Rules }
|
||||
|
||||
export const ratesTypes = {
|
||||
None: {key: "NONE", name: "0 ISK"},
|
||||
@@ -22,7 +25,37 @@ export const ratesTypes = {
|
||||
|
||||
export type Rate = { key: RuleClauseResponseRateEnum, name: string }
|
||||
|
||||
export const findByCharacterId = (characterId: number): Promise<RuleBook> => ruleBookControllerApi.findByCharacterId(characterId)
|
||||
export const useRuleBooksStore = defineStore('rule-books', () => {
|
||||
const ruleBooks = ref<RuleBook[]>([]);
|
||||
|
||||
const addRuleBook = (ruleBook: RuleBook) => {
|
||||
ruleBooks.value.push(ruleBook);
|
||||
triggerRef(ruleBooks);
|
||||
return ruleBook;
|
||||
};
|
||||
|
||||
const replaceRuleBook = (ruleBook: RuleBook) => {
|
||||
const index = ruleBooks.value.findIndex(rb => rb.ruleBookId === ruleBook.ruleBookId);
|
||||
|
||||
if (index !== -1) {
|
||||
ruleBooks.value[index] = ruleBook;
|
||||
}
|
||||
triggerRef(ruleBooks);
|
||||
return ruleBook;
|
||||
};
|
||||
|
||||
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 refresh = () => ruleBookControllerApi.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)
|
||||
.then(response => response.data)
|
||||
.catch(() => ({characterId, rules: {}}));
|
||||
|
||||
|
||||
+9
-1
@@ -72,9 +72,17 @@
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
@apply p-0 border-none bg-transparent hover:text-slate-400 hover:bg-transparent;
|
||||
@apply p-0 border-none bg-transparent hover:text-slate-400 hover:bg-transparent cursor-pointer;
|
||||
> svg {
|
||||
@apply w-6 h-6;
|
||||
}
|
||||
}
|
||||
|
||||
a.tab {
|
||||
@apply flex items-center px-4 me-2 rounded-t-md bg-slate-600 hover:bg-slate-700;
|
||||
|
||||
&.router-link-active {
|
||||
@apply bg-emerald-500 hover:bg-emerald-700;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user