aloha-vue 2.69.0 → 2.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
- import {
2
- computed,
3
- nextTick,
1
+ import {
2
+ computed,
3
+ h,
4
+ nextTick,
4
5
  reactive,
5
6
  ref,
6
7
  } from "vue";
@@ -443,7 +444,7 @@ describe("ATableForm list view", () => {
443
444
  expect(wrapper.findComponent(AForm).props("readonly")).toBe(false);
444
445
  });
445
446
 
446
- it("allows DND but not row-click editing when rows are not editable", async() => {
447
+ it("allows DND but not row-click editing when rows are not editable", async() => {
447
448
  const wrapper = mount(ATableForm, {
448
449
  props: {
449
450
  columns: [
@@ -465,8 +466,112 @@ describe("ATableForm list view", () => {
465
466
 
466
467
  await wrapper.find("tbody tr.a_table_form__row").trigger("click");
467
468
 
468
- expect(wrapper.find("tbody button[id$='_save']").exists()).toBe(false);
469
- });
469
+ expect(wrapper.find("tbody button[id$='_save']").exists()).toBe(false);
470
+ });
471
+
472
+ it("renders a matching row as one full-width cell", async() => {
473
+ const rows = [
474
+ {
475
+ id: 1,
476
+ name: "Section",
477
+ type: "separator",
478
+ },
479
+ {
480
+ id: 2,
481
+ name: "Regular row",
482
+ type: "data",
483
+ },
484
+ ];
485
+ const fullWidthRowCallback = jest.fn(({ row }) => row.type === "separator");
486
+ const wrapper = mount(ATableForm, {
487
+ props: {
488
+ columns: [
489
+ {
490
+ id: "id",
491
+ label: "ID",
492
+ },
493
+ {
494
+ id: "name",
495
+ label: "Name",
496
+ },
497
+ ],
498
+ fullWidthRowCallback,
499
+ isDragAndDrop: true,
500
+ isEditable: true,
501
+ isEditOnRowClick: true,
502
+ keyId: "id",
503
+ rows,
504
+ },
505
+ slots: {
506
+ fullWidthRow: ({ isFooter, row, rowIndex, rows: rowsSlot }) => h("strong", {
507
+ class: "full-width-row-content",
508
+ "data-is-footer": `${ isFooter }`,
509
+ "data-row-index": rowIndex,
510
+ "data-rows-length": rowsSlot.length,
511
+ }, row.name),
512
+ },
513
+ });
514
+
515
+ const bodyRows = wrapper.findAll("tbody tr.a_table_form__row");
516
+ const fullWidthCell = bodyRows[0].find(".a_table_form__cell_full_width");
517
+
518
+ expect(bodyRows).toHaveLength(2);
519
+ expect(bodyRows[0].findAll("td")).toHaveLength(1);
520
+ expect(fullWidthCell.attributes("colspan")).toBe("4");
521
+ expect(fullWidthCell.text()).toBe("Section");
522
+ expect(fullWidthCell.find(".full-width-row-content").attributes()).toEqual(expect.objectContaining({
523
+ "data-is-footer": "false",
524
+ "data-row-index": "0",
525
+ "data-rows-length": "2",
526
+ }));
527
+ expect(bodyRows[0].find(".a_table_form__cell_reorder").exists()).toBe(false);
528
+ expect(bodyRows[0].find(".a_table_form__cell_actions").exists()).toBe(false);
529
+ expect(bodyRows[0].classes()).not.toContain("a_table_form__row_edit_on_click");
530
+ expect(bodyRows[1].findAll("td")).toHaveLength(4);
531
+ expect(bodyRows[1].classes()).toContain("a_table_form__row_edit_on_click");
532
+ expect(fullWidthRowCallback).toHaveBeenCalledWith({
533
+ isFooter: false,
534
+ row: rows[0],
535
+ rowIndex: 0,
536
+ });
537
+
538
+ await bodyRows[0].trigger("click");
539
+
540
+ expect(wrapper.find("tbody button[id$='_save']").exists()).toBe(false);
541
+ });
542
+
543
+ it("renders matching footer rows through the full-width slot", () => {
544
+ const footerRow = {
545
+ label: "Summary",
546
+ type: "summary",
547
+ };
548
+ const wrapper = mount(ATableForm, {
549
+ props: {
550
+ columns: [
551
+ {
552
+ id: "name",
553
+ label: "Name",
554
+ },
555
+ {
556
+ id: "value",
557
+ label: "Value",
558
+ },
559
+ ],
560
+ fullWidthRowCallback: ({ row }) => row.type === "summary",
561
+ rows: [{ name: "Item", value: 1 }],
562
+ rowsFooter: [footerRow],
563
+ },
564
+ slots: {
565
+ fullWidthRow: ({ isFooter, row }) => h("span", `${ isFooter }:${ row.label }`),
566
+ },
567
+ });
568
+
569
+ const footerCells = wrapper.findAll("tfoot td");
570
+
571
+ expect(footerCells).toHaveLength(1);
572
+ expect(footerCells[0].attributes("colspan")).toBe("2");
573
+ expect(footerCells[0].text()).toBe("true:Summary");
574
+ });
470
575
 
471
576
  it("enters edit mode by row click only when enabled and row edit is available", async() => {
472
577
  const rows = [