add specialTrainingAction action
This commit is contained in:
+27
-25
@@ -20,6 +20,7 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
|
||||
roll: DeltaGreenActorSheet._onRoll,
|
||||
resetBreakingPoint: DeltaGreenActorSheet._resetBreakingPoint,
|
||||
typedSkillAction: DeltaGreenActorSheet._onTypedSkillAction,
|
||||
specialTrainingAction: DeltaGreenActorSheet._onSpecialTrainingAction,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -601,6 +602,30 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
|
||||
}
|
||||
}
|
||||
|
||||
static _onSpecialTrainingAction(event, target) {
|
||||
const { actionType, id } = target.dataset;
|
||||
switch (actionType) {
|
||||
case "delete":
|
||||
{
|
||||
const specialTrainingArray = foundry.utils.duplicate(
|
||||
this.actor.system.specialTraining,
|
||||
);
|
||||
|
||||
// Get the index of the training to be deleted
|
||||
const index = specialTrainingArray.findIndex(
|
||||
(training) => training.id === id,
|
||||
);
|
||||
|
||||
specialTrainingArray.splice(index, 1);
|
||||
this.actor.update({ "system.specialTraining": specialTrainingArray });
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this._showSpecialTrainingDialog(actionType, id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
@@ -632,29 +657,6 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
|
||||
});
|
||||
}
|
||||
|
||||
html.find(".special-training-action").click((event) => {
|
||||
event.preventDefault();
|
||||
const action = event.currentTarget.getAttribute("data-action");
|
||||
const targetID = event.currentTarget.getAttribute("data-id");
|
||||
this._showSpecialTrainingDialog(action, targetID);
|
||||
});
|
||||
|
||||
// Handle deletion of Special Training
|
||||
html.find(".special-training-delete").click((event) => {
|
||||
event.preventDefault();
|
||||
const targetID = event.currentTarget.getAttribute("data-id");
|
||||
const specialTrainingArray = foundry.utils.duplicate(
|
||||
this.actor.system.specialTraining,
|
||||
);
|
||||
// Get the index of the training to be deleted
|
||||
const index = specialTrainingArray.findIndex(
|
||||
(training) => training.id === targetID,
|
||||
);
|
||||
|
||||
specialTrainingArray.splice(index, 1);
|
||||
this.actor.update({ "system.specialTraining": specialTrainingArray });
|
||||
});
|
||||
|
||||
html.find(".apply-skill-improvements").click((event) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -1175,12 +1177,12 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
|
||||
const specialTrainingAttribute = btn
|
||||
.find("[name='special-training-skill']")
|
||||
.val();
|
||||
if (action === "Create")
|
||||
if (action === "create")
|
||||
this._createSpecialTraining(
|
||||
specialTrainingLabel,
|
||||
specialTrainingAttribute,
|
||||
);
|
||||
if (action === "Edit")
|
||||
if (action === "edit")
|
||||
this._editSpecialTraining(
|
||||
specialTrainingLabel,
|
||||
specialTrainingAttribute,
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
{{localize 'DG.Skills.AddTypedOrCustomSkill'}}
|
||||
</a>
|
||||
|
||||
<a class="item-control special-training-action action-pill"
|
||||
data-action="Create">
|
||||
<a class="item-control action-pill"
|
||||
data-action="specialTrainingAction"
|
||||
data-action-type="create">
|
||||
<i class="fas fa-plus"></i>
|
||||
{{localize 'DG.SpecialTraining.Dialog.CreateSpecialTraining'}}
|
||||
</a>
|
||||
@@ -97,11 +98,14 @@
|
||||
<i class="fas fa-dice"></i>
|
||||
</label>
|
||||
<div class="item-controls skill-and-training-controls">
|
||||
<a class="item-control special-training-action"
|
||||
data-action="Edit"
|
||||
<a class="item-control"
|
||||
data-action="specialTrainingAction"
|
||||
data-action-type="edit"
|
||||
data-id="{{skill.id}}"
|
||||
title="Edit Training"><i class="fas fa-edit"></i></a>
|
||||
<a class="item-control special-training-delete"
|
||||
<a class="item-control"
|
||||
data-action="specialTrainingAction"
|
||||
data-action-type="delete"
|
||||
title="Delete Training"
|
||||
data-id="{{skill.id}}"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user