Skip to content

Commit

Permalink
SAK-42090 Associated labels for fields properly (sakaiproject#7540)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Nov 12, 2019
1 parent f97f49f commit d28b9f8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export class SakaiRubricCriterionEdit extends RubricsElement {

super();

this.listeners = { "tap": "hostEventCatch" };
this.token = "";
this.criterion = {};
this.criterionClone = {};
Expand All @@ -23,18 +22,19 @@ export class SakaiRubricCriterionEdit extends RubricsElement {
};
}

attributeChangedCallback(name, oldValue, newValue) {
set criterion(newValue) {

super.attributeChangedCallback(name, oldValue, newValue);

if ("criterion" === name) {
this.criterionClone = JSON.parse(newValue);
if (this.criterionClone.new) {
this.updateComplete.then(() => this.querySelector(".edit").click() );
}
let oldValue = this._criterion;
this._criterion = newValue;
this.criterionClone = JSON.parse(JSON.stringify(newValue));
this.requestUpdate("criterion", oldValue);
if (this.criterionClone.new) {
this.updateComplete.then(() => this.querySelector(".edit").click() );
}
}

get criterion() { return this._criterion; }

render() {

return html`
Expand All @@ -54,13 +54,13 @@ export class SakaiRubricCriterionEdit extends RubricsElement {
</div>
<div class="popover-content form">
<div class="form-group">
<label>
<label for="criterion-title-field-${this.criterion.id}">
<sr-lang key="criterion_title">Criterion Title</sr-lang>
</label>
<input id="criterion-title-field-${this.criterion.id}" type="text" class="form-control" value="${this.criterionClone.title}" maxlength="255">
</div>
<div class="form-group">
<label>
<label for="criterion-description-field-${this.criterion.id}">
<sr-lang key="criterion_description">Criterion Description</sr-lang>
</label>
<textarea id="criterion-description-field-${this.criterion.id}" class="form-control">${this.criterionClone.description}</textarea>
Expand All @@ -74,13 +74,6 @@ export class SakaiRubricCriterionEdit extends RubricsElement {
e.target.closest('.criterion-row').classList.add("focused");
}

hostEventCatch(e) {

// catch and stop taps from bubbling outside the component
e.stopPropagation();
console.log('event stopped at host');
}

closeOpen() {
$('.show-tooltip .cancel').click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ export class SakaiRubricCriterionRatingEdit extends RubricsElement {
<div class="popover-content form">
<div class="first-row">
<div class="form-group title">
<label for="rating-title"><sr-lang key="rating_title" /></label>
<label for="rating-title-${this.rating.id}"><sr-lang key="rating_title" /></label>
<input type="text" id="rating-title-${this.rating.id}" class="form-control" .value="${this.rating.title}" maxlength="255">
</div>
<div class="form-group points">
<label for="rating-points"><sr-lang key="points" /></label>
<label for="rating-points-${this.rating.id}"><sr-lang key="points" /></label>
<input type="number" id="rating-points-${this.rating.id}" class="form-control hide-input-arrows" name="quantity" .value="${this.rating.points}" min="${this.minpoints}" max="${this.maxpoints}">
</div>
</div>
<div class="form-group">
<label for=""><sr-lang key="rating_description" /></label>
<label for="rating-description-${this.rating.id}"><sr-lang key="rating_description" /></label>
<textarea name="" id="rating-description-${this.rating.id}" class="form-control">${this.rating.description}</textarea>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class SakaiRubricEdit extends RubricsElement {
<label for="rubric_title_edit">
<sr-lang key="rubric_title">Rubric Title</sr-lang>
</label>
<input title="${tr("rubric_title")}" name="rubric_title_edit" type="text" class="form-control" value="${this.rubricClone.title}" maxlength="255">
<input title="${tr("rubric_title")}" id="rubric_title_edit" type="text" class="form-control" value="${this.rubricClone.title}" maxlength="255">
</div>
</div>
</div>
Expand Down Expand Up @@ -146,7 +146,7 @@ export class SakaiRubricEdit extends RubricsElement {
saveEdit(e) {

e.stopPropagation();
var title = this.querySelector("[name='rubric_title_edit']").value;
var title = this.querySelector("#rubric_title_edit").value;
this.dispatchEvent(new CustomEvent("update-rubric-title", { detail: title }));
$(`#edit_rubric_${this.rubric.id}`).hide();
this.hideToolTip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ export class SakaiRubricGradingComment extends RubricsElement {
<div class="arrow"></div>
<div class="popover-title" style="display: flex;">
<div style="flex: auto;">
<label class="criterion-title" for="">
<span class="criterion-title">
<sr-lang key="comment_for_criterion" values="${JSON.stringify([this.criterion.title])}" />
</label>
</span>
</div>
<div class="buttons act" style="flex: 0">
<button class="active btn-xs done" @click="${this.hideTooltip}"><sr-lang key="done" /></button>
</div>
</div>
<div class="popover-content form">
<div class="form-group">
<textarea aria-labelledby="${tr("criterion_comment")}" class="form-control" name="rbcs-${this.evaluatedItemId}-${this.entityId}-criterion-comment-${this.criterion.id}" id="criterion_${this.evaluatedItemId}_${this.entityId}_comment_${this.criterion.id}|${this.randombit}|">${this.criterion.comments}</textarea>
<textarea aria-label="${tr("criterion_comment")}" class="form-control" name="rbcs-${this.evaluatedItemId}-${this.entityId}-criterion-comment-${this.criterion.id}" id="criterion_${this.evaluatedItemId}_${this.entityId}_comment_${this.criterion.id}|${this.randombit}|">${this.criterion.comments}</textarea>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export class SakaiRubricStudentComment extends RubricsElement {
<div class="arrow"></div>
<div class="popover-title" style="display: flex;">
<div style="flex: auto;">
<label class="criterion-title" for="">
<span class="criterion-title">
<sr-lang key="comment_for_criterion" values="${JSON.stringify([this.criterion.title])}" />
</label>
</span>
</div>
<div class="buttons act" style="flex: 0;">
<button class="active btn-xs done" @click="${this.toggleComment}"><sr-lang key="done" /></button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class SakaiRubricsLanguage extends RubricsElement {
}

translate(key) {

return tr(key, this.values);
}

Expand Down

0 comments on commit d28b9f8

Please sign in to comment.