@allurereport/web-allure2
Version:
The static files for Allure Classic Report
86 lines (73 loc) • 2.68 kB
JavaScript
import { Model } from "backbone";
import { View } from "backbone.marionette";
import $ from "jquery";
import AttachmentView from "@/components/attachment/AttachmentView.js";
import { className, on } from "@/decorators/index.js";
import router from "@/router.js";
import { makeArray } from "@/utils/arrays.js";
import template from "./TestResultExecutionView.hbs";
import "./styles.scss";
class TestResultExecutionView extends View {
template = template;
initialize() {
this.state = new Model();
this.routeState = this.options.routeState;
this.listenTo(this.state, "change:attachment", this.highlightSelectedAttachment, this);
}
onRender() {
const attachment = this.routeState.get("attachment");
if (attachment) {
this.highlightSelectedAttachment(attachment);
}
}
highlightSelectedAttachment(currentAttachment) {
this.$(".attachment-row").removeClass("attachment-row_selected");
const attachmentEl = this.$(`.attachment-row[data-uid="${currentAttachment}"]`);
attachmentEl.addClass("attachment-row_selected");
attachmentEl.parents(".step").addClass("step_expanded");
}
serializeData() {
const before = makeArray(this.model.get("beforeStages"));
const test = makeArray(this.model.get("testStage"));
const after = makeArray(this.model.get("afterStages"));
return {
hasContent: before.length + test.length + after.length > 0,
before: before,
test: test,
after: after,
baseUrl: this.options.baseUrl,
};
}
onStepClick(e) {
this.$(e.currentTarget).parent().toggleClass("step_expanded");
}
onAttachmentClick(e) {
const attachmentUid = $(e.currentTarget).data("uid");
const name = `attachment__${attachmentUid}`;
if ($(e.currentTarget).hasClass("attachment-row_selected") && this.getRegion(name)) {
this.getRegion(name).destroy();
} else {
this.addRegion(name, { el: this.$(`.${name}`) });
this.getRegion(name).show(
new AttachmentView({
attachment: this.model.getAttachment(attachmentUid),
}),
);
}
this.$(e.currentTarget).toggleClass("attachment-row_selected");
}
onAttachmnetFullScrennClick(e) {
const attachment = $(e.currentTarget).closest(".attachment-row").data("uid");
router.setSearch({ attachment });
e.stopPropagation();
}
onParameterClick(e) {
this.$(e.target).siblings().addBack().toggleClass("line-ellipsis");
}
}
export default TestResultExecutionView;