Compare commits
No commits in common. "fe19a98829360b99186a13c48dda185730fb8ee8" and "43e6c04ecd3ab07b3b1f75d07528477dbc998303" have entirely different histories.
fe19a98829
...
43e6c04ecd
|
@ -64,13 +64,6 @@ message UpdateMeritsRequest {
|
||||||
repeated CofdSheet.Merit merits = 2;
|
repeated CofdSheet.Merit merits = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update all items on the character sheet by overwriting them.
|
|
||||||
//Primarily for the web UI.
|
|
||||||
message UpdateItemsRequest {
|
|
||||||
CharacterIdentifier character = 1;
|
|
||||||
repeated CofdSheet.Item items = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add a Condition to a Chronicles of Darkness character sheet.
|
//Add a Condition to a Chronicles of Darkness character sheet.
|
||||||
message AddConditionRequest {
|
message AddConditionRequest {
|
||||||
string character_username = 1;
|
string character_username = 1;
|
||||||
|
|
|
@ -236,34 +236,6 @@ export namespace UpdateMeritsRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateItemsRequest extends jspb.Message {
|
|
||||||
hasCharacter(): boolean;
|
|
||||||
clearCharacter(): void;
|
|
||||||
getCharacter(): CharacterIdentifier | undefined;
|
|
||||||
setCharacter(value?: CharacterIdentifier): void;
|
|
||||||
|
|
||||||
clearItemsList(): void;
|
|
||||||
getItemsList(): Array<cofd_pb.CofdSheet.Item>;
|
|
||||||
setItemsList(value: Array<cofd_pb.CofdSheet.Item>): void;
|
|
||||||
addItems(value?: cofd_pb.CofdSheet.Item, index?: number): cofd_pb.CofdSheet.Item;
|
|
||||||
|
|
||||||
serializeBinary(): Uint8Array;
|
|
||||||
toObject(includeInstance?: boolean): UpdateItemsRequest.AsObject;
|
|
||||||
static toObject(includeInstance: boolean, msg: UpdateItemsRequest): UpdateItemsRequest.AsObject;
|
|
||||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
||||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
||||||
static serializeBinaryToWriter(message: UpdateItemsRequest, writer: jspb.BinaryWriter): void;
|
|
||||||
static deserializeBinary(bytes: Uint8Array): UpdateItemsRequest;
|
|
||||||
static deserializeBinaryFromReader(message: UpdateItemsRequest, reader: jspb.BinaryReader): UpdateItemsRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
export namespace UpdateItemsRequest {
|
|
||||||
export type AsObject = {
|
|
||||||
character?: CharacterIdentifier.AsObject,
|
|
||||||
itemsList: Array<cofd_pb.CofdSheet.Item.AsObject>,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class AddConditionRequest extends jspb.Message {
|
export class AddConditionRequest extends jspb.Message {
|
||||||
getCharacterUsername(): string;
|
getCharacterUsername(): string;
|
||||||
setCharacterUsername(value: string): void;
|
setCharacterUsername(value: string): void;
|
||||||
|
|
|
@ -22,7 +22,6 @@ goog.exportSymbol('proto.models.proto.cofd.api.CharacterIdentifier', null, globa
|
||||||
goog.exportSymbol('proto.models.proto.cofd.api.RemoveConditionRequest', null, global);
|
goog.exportSymbol('proto.models.proto.cofd.api.RemoveConditionRequest', null, global);
|
||||||
goog.exportSymbol('proto.models.proto.cofd.api.UpdateAttributeRequest', null, global);
|
goog.exportSymbol('proto.models.proto.cofd.api.UpdateAttributeRequest', null, global);
|
||||||
goog.exportSymbol('proto.models.proto.cofd.api.UpdateBasicInfoRequest', null, global);
|
goog.exportSymbol('proto.models.proto.cofd.api.UpdateBasicInfoRequest', null, global);
|
||||||
goog.exportSymbol('proto.models.proto.cofd.api.UpdateItemsRequest', null, global);
|
|
||||||
goog.exportSymbol('proto.models.proto.cofd.api.UpdateMeritsRequest', null, global);
|
goog.exportSymbol('proto.models.proto.cofd.api.UpdateMeritsRequest', null, global);
|
||||||
goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillRequest', null, global);
|
goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillRequest', null, global);
|
||||||
goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillSpecializationsRequest', null, global);
|
goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillSpecializationsRequest', null, global);
|
||||||
|
@ -195,27 +194,6 @@ if (goog.DEBUG && !COMPILED) {
|
||||||
*/
|
*/
|
||||||
proto.models.proto.cofd.api.UpdateMeritsRequest.displayName = 'proto.models.proto.cofd.api.UpdateMeritsRequest';
|
proto.models.proto.cofd.api.UpdateMeritsRequest.displayName = 'proto.models.proto.cofd.api.UpdateMeritsRequest';
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Generated by JsPbCodeGenerator.
|
|
||||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
|
||||||
* server response, or constructed directly in Javascript. The array is used
|
|
||||||
* in place and becomes part of the constructed object. It is not cloned.
|
|
||||||
* If no data is provided, the constructed object will be empty, but still
|
|
||||||
* valid.
|
|
||||||
* @extends {jspb.Message}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest = function(opt_data) {
|
|
||||||
jspb.Message.initialize(this, opt_data, 0, -1, proto.models.proto.cofd.api.UpdateItemsRequest.repeatedFields_, null);
|
|
||||||
};
|
|
||||||
goog.inherits(proto.models.proto.cofd.api.UpdateItemsRequest, jspb.Message);
|
|
||||||
if (goog.DEBUG && !COMPILED) {
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
* @override
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.displayName = 'proto.models.proto.cofd.api.UpdateItemsRequest';
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Generated by JsPbCodeGenerator.
|
* Generated by JsPbCodeGenerator.
|
||||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||||
|
@ -1901,217 +1879,6 @@ proto.models.proto.cofd.api.UpdateMeritsRequest.prototype.clearMeritsList = func
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of repeated fields within this message type.
|
|
||||||
* @private {!Array<number>}
|
|
||||||
* @const
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.repeatedFields_ = [2];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
|
||||||
/**
|
|
||||||
* Creates an object representation of this proto.
|
|
||||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
|
||||||
* Optional fields that are not set will be set to undefined.
|
|
||||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
|
||||||
* For the list of reserved names please see:
|
|
||||||
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
|
|
||||||
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
|
|
||||||
* JSPB instance for transitional soy proto support:
|
|
||||||
* http://goto/soy-param-migration
|
|
||||||
* @return {!Object}
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.toObject = function(opt_includeInstance) {
|
|
||||||
return proto.models.proto.cofd.api.UpdateItemsRequest.toObject(opt_includeInstance, this);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static version of the {@see toObject} method.
|
|
||||||
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
|
|
||||||
* the JSPB instance for transitional soy proto support:
|
|
||||||
* http://goto/soy-param-migration
|
|
||||||
* @param {!proto.models.proto.cofd.api.UpdateItemsRequest} msg The msg instance to transform.
|
|
||||||
* @return {!Object}
|
|
||||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.toObject = function(includeInstance, msg) {
|
|
||||||
var f, obj = {
|
|
||||||
character: (f = msg.getCharacter()) && proto.models.proto.cofd.api.CharacterIdentifier.toObject(includeInstance, f),
|
|
||||||
itemsList: jspb.Message.toObjectList(msg.getItemsList(),
|
|
||||||
cofd_pb.CofdSheet.Item.toObject, includeInstance)
|
|
||||||
};
|
|
||||||
|
|
||||||
if (includeInstance) {
|
|
||||||
obj.$jspbMessageInstance = msg;
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes binary data (in protobuf wire format).
|
|
||||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
|
||||||
* @return {!proto.models.proto.cofd.api.UpdateItemsRequest}
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.deserializeBinary = function(bytes) {
|
|
||||||
var reader = new jspb.BinaryReader(bytes);
|
|
||||||
var msg = new proto.models.proto.cofd.api.UpdateItemsRequest;
|
|
||||||
return proto.models.proto.cofd.api.UpdateItemsRequest.deserializeBinaryFromReader(msg, reader);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes binary data (in protobuf wire format) from the
|
|
||||||
* given reader into the given message object.
|
|
||||||
* @param {!proto.models.proto.cofd.api.UpdateItemsRequest} msg The message object to deserialize into.
|
|
||||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
|
||||||
* @return {!proto.models.proto.cofd.api.UpdateItemsRequest}
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.deserializeBinaryFromReader = function(msg, reader) {
|
|
||||||
while (reader.nextField()) {
|
|
||||||
if (reader.isEndGroup()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
var field = reader.getFieldNumber();
|
|
||||||
switch (field) {
|
|
||||||
case 1:
|
|
||||||
var value = new proto.models.proto.cofd.api.CharacterIdentifier;
|
|
||||||
reader.readMessage(value,proto.models.proto.cofd.api.CharacterIdentifier.deserializeBinaryFromReader);
|
|
||||||
msg.setCharacter(value);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
var value = new cofd_pb.CofdSheet.Item;
|
|
||||||
reader.readMessage(value,cofd_pb.CofdSheet.Item.deserializeBinaryFromReader);
|
|
||||||
msg.addItems(value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
reader.skipField();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return msg;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the message to binary data (in protobuf wire format).
|
|
||||||
* @return {!Uint8Array}
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.serializeBinary = function() {
|
|
||||||
var writer = new jspb.BinaryWriter();
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.serializeBinaryToWriter(this, writer);
|
|
||||||
return writer.getResultBuffer();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the given message to binary data (in protobuf wire
|
|
||||||
* format), writing to the given BinaryWriter.
|
|
||||||
* @param {!proto.models.proto.cofd.api.UpdateItemsRequest} message
|
|
||||||
* @param {!jspb.BinaryWriter} writer
|
|
||||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.serializeBinaryToWriter = function(message, writer) {
|
|
||||||
var f = undefined;
|
|
||||||
f = message.getCharacter();
|
|
||||||
if (f != null) {
|
|
||||||
writer.writeMessage(
|
|
||||||
1,
|
|
||||||
f,
|
|
||||||
proto.models.proto.cofd.api.CharacterIdentifier.serializeBinaryToWriter
|
|
||||||
);
|
|
||||||
}
|
|
||||||
f = message.getItemsList();
|
|
||||||
if (f.length > 0) {
|
|
||||||
writer.writeRepeatedMessage(
|
|
||||||
2,
|
|
||||||
f,
|
|
||||||
cofd_pb.CofdSheet.Item.serializeBinaryToWriter
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* optional CharacterIdentifier character = 1;
|
|
||||||
* @return {?proto.models.proto.cofd.api.CharacterIdentifier}
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.getCharacter = function() {
|
|
||||||
return /** @type{?proto.models.proto.cofd.api.CharacterIdentifier} */ (
|
|
||||||
jspb.Message.getWrapperField(this, proto.models.proto.cofd.api.CharacterIdentifier, 1));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?proto.models.proto.cofd.api.CharacterIdentifier|undefined} value
|
|
||||||
* @return {!proto.models.proto.cofd.api.UpdateItemsRequest} returns this
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.setCharacter = function(value) {
|
|
||||||
return jspb.Message.setWrapperField(this, 1, value);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the message field making it undefined.
|
|
||||||
* @return {!proto.models.proto.cofd.api.UpdateItemsRequest} returns this
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.clearCharacter = function() {
|
|
||||||
return this.setCharacter(undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this field is set.
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.hasCharacter = function() {
|
|
||||||
return jspb.Message.getField(this, 1) != null;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* repeated models.proto.cofd.CofdSheet.Item items = 2;
|
|
||||||
* @return {!Array<!proto.models.proto.cofd.CofdSheet.Item>}
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.getItemsList = function() {
|
|
||||||
return /** @type{!Array<!proto.models.proto.cofd.CofdSheet.Item>} */ (
|
|
||||||
jspb.Message.getRepeatedWrapperField(this, cofd_pb.CofdSheet.Item, 2));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {!Array<!proto.models.proto.cofd.CofdSheet.Item>} value
|
|
||||||
* @return {!proto.models.proto.cofd.api.UpdateItemsRequest} returns this
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.setItemsList = function(value) {
|
|
||||||
return jspb.Message.setRepeatedWrapperField(this, 2, value);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {!proto.models.proto.cofd.CofdSheet.Item=} opt_value
|
|
||||||
* @param {number=} opt_index
|
|
||||||
* @return {!proto.models.proto.cofd.CofdSheet.Item}
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.addItems = function(opt_value, opt_index) {
|
|
||||||
return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.models.proto.cofd.CofdSheet.Item, opt_index);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the list making it empty but non-null.
|
|
||||||
* @return {!proto.models.proto.cofd.api.UpdateItemsRequest} returns this
|
|
||||||
*/
|
|
||||||
proto.models.proto.cofd.api.UpdateItemsRequest.prototype.clearItemsList = function() {
|
|
||||||
return this.setItemsList([]);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as jspb from "google-protobuf";
|
import * as jspb from "google-protobuf";
|
||||||
import { ApiResult, UpdateBasicInfoRequest, UpdateAttributeRequest, UpdateSkillValueRequest, UpdateMeritsRequest, UpdateItemsRequest } from "../_proto/cofd_api_pb";
|
import { ApiResult, UpdateBasicInfoRequest, UpdateAttributeRequest, UpdateSkillValueRequest, UpdateMeritsRequest } from "../_proto/cofd_api_pb";
|
||||||
|
|
||||||
const PROTOBUF_CONTENT_TYPE = { 'Content-Type': 'application/x-protobuf' };
|
const PROTOBUF_CONTENT_TYPE = { 'Content-Type': 'application/x-protobuf' };
|
||||||
|
|
||||||
|
@ -33,8 +33,3 @@ export async function updateMerits(params: UpdateMeritsRequest): Promise<ApiResu
|
||||||
let data = await makeRequest('/api/rpc/cofd/update_merits', params);
|
let data = await makeRequest('/api/rpc/cofd/update_merits', params);
|
||||||
return ApiResult.deserializeBinary(data);
|
return ApiResult.deserializeBinary(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateItems(params: UpdateItemsRequest): Promise<ApiResult> {
|
|
||||||
let data = await makeRequest('/api/rpc/cofd/update_items', params);
|
|
||||||
return ApiResult.deserializeBinary(data);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
export function addMeritLine(parent: Element) {
|
|
||||||
const meritName = document.createElement('input');
|
|
||||||
meritName.type = 'text';
|
|
||||||
meritName.value = '';
|
|
||||||
meritName.classList.add('merit-name');
|
|
||||||
|
|
||||||
const meritDots = document.createElement('input');
|
|
||||||
meritDots.type = 'number';
|
|
||||||
meritDots.min = '0';
|
|
||||||
meritDots.value = '0';
|
|
||||||
meritDots.classList.add('merit-dots');
|
|
||||||
|
|
||||||
const removeButton = document.createElement('button');
|
|
||||||
removeButton.innerText = "X";
|
|
||||||
removeButton.setAttribute('data-event-type', 'remove-merit');
|
|
||||||
removeButton.classList.add('remove-merit');
|
|
||||||
|
|
||||||
const dots = document.createElement('span');
|
|
||||||
dots.innerText = 'Dots';
|
|
||||||
|
|
||||||
const merit = document.createElement('div');
|
|
||||||
merit.classList.add('merit');
|
|
||||||
merit.appendChild(meritName);
|
|
||||||
merit.appendChild(meritDots);
|
|
||||||
merit.appendChild(dots);
|
|
||||||
merit.appendChild(removeButton);
|
|
||||||
|
|
||||||
parent.appendChild(merit);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function addItemLine(parent: Element) {
|
|
||||||
const itemName = document.createElement('input');
|
|
||||||
itemName.type = 'text';
|
|
||||||
itemName.value = '';
|
|
||||||
itemName.classList.add('item-name');
|
|
||||||
|
|
||||||
const removeButton = document.createElement('button');
|
|
||||||
removeButton.innerText = "X";
|
|
||||||
removeButton.setAttribute('data-event-type', 'remove-item');
|
|
||||||
removeButton.classList.add('remove-item');
|
|
||||||
|
|
||||||
const item = document.createElement('div');
|
|
||||||
item.classList.add('item');
|
|
||||||
item.appendChild(itemName);
|
|
||||||
item.appendChild(removeButton);
|
|
||||||
|
|
||||||
parent.appendChild(item);
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { CharacterIdentifier, UpdateBasicInfoRequest, UpdateSkillValueRequest, UpdateAttributeRequest, UpdateMeritsRequest, UpdateItemsRequest } from "../../_proto/cofd_api_pb";
|
import { CharacterIdentifier, UpdateBasicInfoRequest, UpdateSkillValueRequest, UpdateAttributeRequest, UpdateMeritsRequest } from "../../_proto/cofd_api_pb";
|
||||||
import { CofdSheet } from "../../_proto/cofd_pb";
|
import { CofdSheet } from "../../_proto/cofd_pb";
|
||||||
import * as api from "../api";
|
import * as api from "../api";
|
||||||
import * as ui from "./edit-ui";
|
|
||||||
|
|
||||||
// This is the scripting for the edit character page, which submits
|
// This is the scripting for the edit character page, which submits
|
||||||
// changes to the server as the user makes them.
|
// changes to the server as the user makes them.
|
||||||
|
@ -130,7 +129,37 @@ import * as ui from "./edit-ui";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processEvent(event: Event) {
|
function addMeritLine() {
|
||||||
|
const meritName = document.createElement('input');
|
||||||
|
meritName.type = 'text';
|
||||||
|
meritName.value = '';
|
||||||
|
meritName.classList.add('merit-name');
|
||||||
|
|
||||||
|
const meritDots = document.createElement('input');
|
||||||
|
meritDots.type = 'number';
|
||||||
|
meritDots.min = '0';
|
||||||
|
meritDots.value = '0';
|
||||||
|
meritDots.classList.add('merit-dots');
|
||||||
|
|
||||||
|
const removeButton = document.createElement('button');
|
||||||
|
removeButton.innerText = "X";
|
||||||
|
removeButton.setAttribute('data-event-type', 'remove-merit');
|
||||||
|
removeButton.classList.add('remove-merit');
|
||||||
|
|
||||||
|
const dots = document.createElement('span');
|
||||||
|
dots.innerText = 'Dots';
|
||||||
|
|
||||||
|
const merit = document.createElement('div');
|
||||||
|
merit.classList.add('merit');
|
||||||
|
merit.appendChild(meritName);
|
||||||
|
merit.appendChild(meritDots);
|
||||||
|
merit.appendChild(dots);
|
||||||
|
merit.appendChild(removeButton);
|
||||||
|
|
||||||
|
document.querySelector<HTMLDivElement>("#merit-list")?.appendChild(merit);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function processControlEvent(event: Event) {
|
||||||
console.log('processing merit control event');
|
console.log('processing merit control event');
|
||||||
const element = event.target as Element;
|
const element = event.target as Element;
|
||||||
const eventType = element.getAttribute('data-event-type') ?? '';
|
const eventType = element.getAttribute('data-event-type') ?? '';
|
||||||
|
@ -138,78 +167,23 @@ import * as ui from "./edit-ui";
|
||||||
if (eventType == 'remove-merit') {
|
if (eventType == 'remove-merit') {
|
||||||
await removeMerit(event);
|
await removeMerit(event);
|
||||||
} else if (eventType == 'add-merit') {
|
} else if (eventType == 'add-merit') {
|
||||||
const meritList = document.querySelector<HTMLDivElement>("#merit-list")!;
|
addMeritLine();
|
||||||
ui.addMeritLine(meritList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const meritControls = document.querySelector<HTMLDivElement>("#merit-controls");
|
const meritControls = document.querySelector<HTMLDivElement>("#merit-controls");
|
||||||
meritControls?.addEventListener('click', processEvent);
|
meritControls?.addEventListener('click', processControlEvent);
|
||||||
|
|
||||||
const meritList = document.querySelector<HTMLDivElement>("#merit-list");
|
const meritList = document.querySelector<HTMLDivElement>("#merit-list");
|
||||||
meritList?.addEventListener('click', processEvent);
|
meritList?.addEventListener('click', processControlEvent);
|
||||||
meritList?.addEventListener('blur', updateMerits);
|
meritList?.addEventListener('blur', updateMerits);
|
||||||
meritList?.addEventListener('change', updateMerits);
|
meritList?.addEventListener('change', updateMerits);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupItems() {
|
|
||||||
async function updateItems() {
|
|
||||||
let meritElements = document.querySelectorAll<HTMLInputElement>('#items input[class="item-name"]');
|
|
||||||
let items: CofdSheet.Item[] =
|
|
||||||
Array.from(meritElements).map(input => {
|
|
||||||
const item = new CofdSheet.Item();
|
|
||||||
item.setName(input.value);
|
|
||||||
item.setDescription(""); //TODO add description
|
|
||||||
item.setRules(""); //TODO add rules
|
|
||||||
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log("items are", items);
|
|
||||||
const params = new UpdateItemsRequest();
|
|
||||||
params.setCharacter(characterId());
|
|
||||||
params.setItemsList(items);
|
|
||||||
|
|
||||||
let resp = await api.updateItems(params);
|
|
||||||
console.log("got a response back", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeItem(event: Event) {
|
|
||||||
const button = event.target as Option<Element>;
|
|
||||||
const itemLine = button?.parentElement;
|
|
||||||
if (itemLine) {
|
|
||||||
document.querySelector("#item-list")?.removeChild(itemLine);
|
|
||||||
await updateItems();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function processEvent(event: Event) {
|
|
||||||
console.log('processing item control event');
|
|
||||||
const element = event.target as Element;
|
|
||||||
const eventType = element.getAttribute('data-event-type') ?? '';
|
|
||||||
|
|
||||||
if (eventType == 'remove-item') {
|
|
||||||
await removeItem(event);
|
|
||||||
} else if (eventType == 'add-item') {
|
|
||||||
const itemList = document.querySelector<HTMLDivElement>("#item-list")!;
|
|
||||||
ui.addItemLine(itemList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const meritControls = document.querySelector<HTMLDivElement>("#item-controls");
|
|
||||||
meritControls?.addEventListener('click', processEvent);
|
|
||||||
|
|
||||||
const meritList = document.querySelector<HTMLDivElement>("#item-list");
|
|
||||||
meritList?.addEventListener('click', processEvent);
|
|
||||||
meritList?.addEventListener('blur', updateItems);
|
|
||||||
meritList?.addEventListener('change', updateItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
setupAttributes();
|
setupAttributes();
|
||||||
setupSkills();
|
setupSkills();
|
||||||
setupBasicInfo();
|
setupBasicInfo();
|
||||||
setupMerits();
|
setupMerits();
|
||||||
setupItems();
|
|
||||||
})().catch(e => {
|
})().catch(e => {
|
||||||
alert(e);
|
alert(e);
|
||||||
});
|
});
|
||||||
|
|
|
@ -108,18 +108,16 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#merits, #items {
|
#merits {
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#merit-list {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
#merit-list, #item-list {
|
.merit {
|
||||||
display: inline-flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.merit, .item {
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
@ -127,7 +125,7 @@
|
||||||
margin-top: -1px;
|
margin-top: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.merit .merit-name, .item .item-name {
|
.merit .merit-name {
|
||||||
width: 10em;
|
width: 10em;
|
||||||
vertical-align: text-bottom;
|
vertical-align: text-bottom;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -153,7 +151,7 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.merit .remove-merit, .item .remove-item {
|
.merit .remove-merit {
|
||||||
max-width: 4em;
|
max-width: 4em;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
|
@ -269,17 +267,5 @@
|
||||||
<button data-event-type="add-merit">Add Merit</button>
|
<button data-event-type="add-merit">Add Merit</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="items">
|
|
||||||
<h2>Inventory</h2>
|
|
||||||
|
|
||||||
<div id="item-list">
|
|
||||||
{% for item in sheet.items %}
|
|
||||||
{{ macros::item(name=item.name) }}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
<div id="item-controls">
|
|
||||||
<button data-event-type="add-item">Add Item</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
@ -19,11 +19,3 @@
|
||||||
<button class="remove-merit" data-event-type="remove-merit">X</button>
|
<button class="remove-merit" data-event-type="remove-merit">X</button>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro merit %}
|
{% endmacro merit %}
|
||||||
|
|
||||||
|
|
||||||
{% macro item(name) %}
|
|
||||||
<div class="item">
|
|
||||||
<input type="text" class="item-name" value="{{name}}" />
|
|
||||||
<button class="remove-item" data-event-type="remove-item">X</button>
|
|
||||||
</div>
|
|
||||||
{% endmacro item %}
|
|
||||||
|
|
|
@ -111,31 +111,31 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#merits, #items {
|
#merits {
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#merit-list {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
#merit-list, #item-list {
|
.merit {
|
||||||
display: inline-flex;
|
/* margin: 0;
|
||||||
flex-direction: column;
|
padding: 0; */
|
||||||
}
|
|
||||||
|
|
||||||
.merit, .item {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
margin-top: -1px;
|
margin-top: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.merit span, .item span {
|
.merit span {
|
||||||
width: 3em;
|
width: 3em;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.merit .merit-name, .item .item-name {
|
.merit .merit-name {
|
||||||
width: 10em;
|
width: 10em;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
@ -153,6 +153,16 @@
|
||||||
background-color: lightgray;
|
background-color: lightgray;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.merit .remove-merit {
|
||||||
|
max-width: 4em;
|
||||||
|
padding: 0;
|
||||||
|
padding: 3px;
|
||||||
|
padding-left: 6px;
|
||||||
|
padding-right:6px;
|
||||||
|
margin: 3px;
|
||||||
|
background-color: lightgray;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -252,16 +262,5 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="items">
|
|
||||||
<h2>Items</h2>
|
|
||||||
<div id="item-list">
|
|
||||||
{% for item in sheet.items %}
|
|
||||||
<div class="item">
|
|
||||||
<span class="item-name">{{item.name}}</span>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
@ -12,7 +12,6 @@ pub(crate) fn routes() -> Vec<rocket::Route> {
|
||||||
cofd::update_skill,
|
cofd::update_skill,
|
||||||
cofd::update_skill_value,
|
cofd::update_skill_value,
|
||||||
cofd::update_merits,
|
cofd::update_merits,
|
||||||
cofd::update_items,
|
|
||||||
cofd::add_condition,
|
cofd::add_condition,
|
||||||
cofd::remove_condition
|
cofd::remove_condition
|
||||||
]
|
]
|
||||||
|
|
|
@ -187,30 +187,6 @@ pub(super) async fn update_merits<'a>(
|
||||||
Ok(Proto(ApiResult::success()))
|
Ok(Proto(ApiResult::success()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/rpc/cofd/update_items", data = "<req>")]
|
|
||||||
pub(super) async fn update_items<'a>(
|
|
||||||
req: Proto<UpdateItemsRequest>,
|
|
||||||
conn: TenebrousDbConn<'_>,
|
|
||||||
logged_in_user: Option<&User>,
|
|
||||||
) -> Result<Proto<ApiResult>, Error> {
|
|
||||||
let mut character = load_character(
|
|
||||||
&conn,
|
|
||||||
logged_in_user,
|
|
||||||
&req.character.owner(),
|
|
||||||
req.character.id(),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let mut sheet: CofdSheet = character.try_deserialize()?;
|
|
||||||
sheet.items = req.items.clone();
|
|
||||||
|
|
||||||
println!("updated items");
|
|
||||||
|
|
||||||
character.update_data(&sheet)?;
|
|
||||||
conn.update_character_sheet(&character).await?;
|
|
||||||
Ok(Proto(ApiResult::success()))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[put("/rpc/cofd/add_condition", data = "<info>")]
|
#[put("/rpc/cofd/add_condition", data = "<info>")]
|
||||||
pub(super) fn add_condition<'a>(info: Proto<AddConditionRequest>) -> &'a str {
|
pub(super) fn add_condition<'a>(info: Proto<AddConditionRequest>) -> &'a str {
|
||||||
"lol"
|
"lol"
|
||||||
|
|
Loading…
Reference in New Issue