View | Details | Raw Unified | Return to bug 37577
Collapse All | Expand All

(-)a/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm (-4 / +6 lines)
Lines 87-100 sub add { Link Here
87
87
88
                my $body = $c->req->json;
88
                my $body = $c->req->json;
89
89
90
                my $package_agreements = delete $body->{package_agreements} // [];
90
                my $package_agreements  = delete $body->{package_agreements}  // [];
91
                my $extended_attributes = delete $body->{extended_attributes} // [];
91
                my $extended_attributes = delete $body->{extended_attributes} // [];
92
                delete $body->{external_id} unless $body->{external_id};
92
                delete $body->{external_id} unless $body->{external_id};
93
93
94
                my $package = Koha::ERM::EHoldings::Package->new_from_api($body)->store;
94
                my $package = Koha::ERM::EHoldings::Package->new_from_api($body)->store;
95
                $package->package_agreements($package_agreements);
95
                $package->package_agreements($package_agreements);
96
96
97
                my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes};
97
                my @extended_attributes =
98
                    map { { 'id' => $_->{field_id}, 'value' => $_->{value} } } @{$extended_attributes};
98
                $package->extended_attributes( \@extended_attributes );
99
                $package->extended_attributes( \@extended_attributes );
99
100
100
                $c->res->headers->location($c->req->url->to_string . '/' . $package->package_id);
101
                $c->res->headers->location($c->req->url->to_string . '/' . $package->package_id);
Lines 163-169 sub update { Link Here
163
164
164
                my $body = $c->req->json;
165
                my $body = $c->req->json;
165
166
166
                my $package_agreements = delete $body->{package_agreements} // [];
167
                my $package_agreements  = delete $body->{package_agreements}  // [];
167
                my $extended_attributes = delete $body->{extended_attributes} // [];
168
                my $extended_attributes = delete $body->{extended_attributes} // [];
168
                delete $body->{external_id} unless $body->{external_id};
169
                delete $body->{external_id} unless $body->{external_id};
169
170
Lines 173-179 sub update { Link Here
173
                # ie. It's coming from EBSCO and we don't have local data linked to it
174
                # ie. It's coming from EBSCO and we don't have local data linked to it
174
                $package->package_agreements($package_agreements);
175
                $package->package_agreements($package_agreements);
175
176
176
                my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes};
177
                my @extended_attributes =
178
                    map { { 'id' => $_->{field_id}, 'value' => $_->{value} } } @{$extended_attributes};
177
                $package->extended_attributes( \@extended_attributes );
179
                $package->extended_attributes( \@extended_attributes );
178
180
179
                $c->res->headers->location($c->req->url->to_string . '/' . $package->package_id);
181
                $c->res->headers->location($c->req->url->to_string . '/' . $package->package_id);
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue (-1 / +1 lines)
Lines 134-140 export default { Link Here
134
                error => {}
134
                error => {}
135
            )
135
            )
136
        },
136
        },
137
	    async getSearchableAdditionalFields() {
137
        async getSearchableAdditionalFields() {
138
            const client = APIClient.additional_fields
138
            const client = APIClient.additional_fields
139
            await client.additional_fields.getAll("package").then(
139
            await client.additional_fields.getAll("package").then(
140
                searchable_additional_fields => {
140
                searchable_additional_fields => {
(-)a/t/cypress/integration/AdditionalFields_spec.ts (-19 / +37 lines)
Lines 269-275 function get_no_additional_fields_package() { Link Here
269
        vendor: [cy.get_vendors_to_relate()[0]],
269
        vendor: [cy.get_vendors_to_relate()[0]],
270
        extended_attributes: [],
270
        extended_attributes: [],
271
        _strings: {
271
        _strings: {
272
            "additional_field_values": []
272
            additional_field_values: [],
273
        },
273
        },
274
    };
274
    };
275
}
275
}
Lines 1274-1280 describe("Additional Fields operations", () => { Link Here
1274
    it("Additional Fields display - Table (eHoldings packages)", () => {
1274
    it("Additional Fields display - Table (eHoldings packages)", () => {
1275
        let eholdings_package = get_package();
1275
        let eholdings_package = get_package();
1276
        let eholdings_packages = [eholdings_package];
1276
        let eholdings_packages = [eholdings_package];
1277
        let eholdings_package_additional_fields = get_packages_additional_fields();
1277
        let eholdings_package_additional_fields =
1278
            get_packages_additional_fields();
1278
        let av_cats = get_av_cats();
1279
        let av_cats = get_av_cats();
1279
1280
1280
        cy.intercept("GET", "/api/v1/extended_attribute_types*", {
1281
        cy.intercept("GET", "/api/v1/extended_attribute_types*", {
Lines 1290-1296 describe("Additional Fields operations", () => { Link Here
1290
                "X-Total-Count": "1",
1291
                "X-Total-Count": "1",
1291
            },
1292
            },
1292
        });
1293
        });
1293
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages/*", eholdings_package);
1294
        cy.intercept(
1295
            "GET",
1296
            "/api/v1/erm/eholdings/local/packages/*",
1297
            eholdings_package
1298
        );
1294
        cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
1299
        cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
1295
        cy.get("#packages_list").contains("Showing 1 to 1 of 1 entries");
1300
        cy.get("#packages_list").contains("Showing 1 to 1 of 1 entries");
1296
1301
Lines 1318-1324 describe("Additional Fields operations", () => { Link Here
1318
        let eholdings_package = get_package();
1323
        let eholdings_package = get_package();
1319
        let eholdings_packages = [eholdings_package];
1324
        let eholdings_packages = [eholdings_package];
1320
        let vendors = cy.get_vendors_to_relate();
1325
        let vendors = cy.get_vendors_to_relate();
1321
        let eholdings_package_additional_fields = get_packages_additional_fields();
1326
        let eholdings_package_additional_fields =
1327
            get_packages_additional_fields();
1322
        let av_cats = get_av_cats();
1328
        let av_cats = get_av_cats();
1323
1329
1324
        // Click the 'Edit' button from the list
1330
        // Click the 'Edit' button from the list
Lines 1330-1338 describe("Additional Fields operations", () => { Link Here
1330
                "X-Total-Count": "1",
1336
                "X-Total-Count": "1",
1331
            },
1337
            },
1332
        });
1338
        });
1333
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages/*", empty_eholdings_package).as(
1339
        cy.intercept(
1334
            "get-empty-eholdings-package"
1340
            "GET",
1335
        );
1341
            "/api/v1/erm/eholdings/local/packages/*",
1342
            empty_eholdings_package
1343
        ).as("get-empty-eholdings-package");
1336
1344
1337
        //Intercept vendors request
1345
        //Intercept vendors request
1338
        cy.intercept("GET", "/api/v1/acquisitions/vendors*", {
1346
        cy.intercept("GET", "/api/v1/acquisitions/vendors*", {
Lines 1368-1376 describe("Additional Fields operations", () => { Link Here
1368
            }
1376
            }
1369
        ).as("avcategories");
1377
        ).as("avcategories");
1370
1378
1371
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages/*", eholdings_package).as(
1379
        cy.intercept(
1372
            "get-eholdings-package"
1380
            "GET",
1373
        );
1381
            "/api/v1/erm/eholdings/local/packages/*",
1382
            eholdings_package
1383
        ).as("get-eholdings-package");
1374
1384
1375
        // There are additional fields, fieldset should exist
1385
        // There are additional fields, fieldset should exist
1376
        cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
1386
        cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
Lines 1437-1443 describe("Additional Fields operations", () => { Link Here
1437
1447
1438
    it("Additional Fields entry - Add (eHoldings packages)", () => {
1448
    it("Additional Fields entry - Add (eHoldings packages)", () => {
1439
        let vendors = cy.get_vendors_to_relate();
1449
        let vendors = cy.get_vendors_to_relate();
1440
        let eholdings_package_additional_fields = get_packages_additional_fields();
1450
        let eholdings_package_additional_fields =
1451
            get_packages_additional_fields();
1441
        let av_cats = get_av_cats();
1452
        let av_cats = get_av_cats();
1442
1453
1443
        //Intercept vendors request
1454
        //Intercept vendors request
Lines 1551-1557 describe("Additional Fields operations", () => { Link Here
1551
        let eholdings_package = get_package();
1562
        let eholdings_package = get_package();
1552
        let eholdings_packages = [eholdings_package];
1563
        let eholdings_packages = [eholdings_package];
1553
        let vendors = cy.get_vendors_to_relate();
1564
        let vendors = cy.get_vendors_to_relate();
1554
        let eholdings_package_additional_fields = get_packages_additional_fields();
1565
        let eholdings_package_additional_fields =
1566
            get_packages_additional_fields();
1555
        let av_cats = get_av_cats();
1567
        let av_cats = get_av_cats();
1556
1568
1557
        // Click the 'Edit' button from the list
1569
        // Click the 'Edit' button from the list
Lines 1563-1571 describe("Additional Fields operations", () => { Link Here
1563
                "X-Total-Count": "1",
1575
                "X-Total-Count": "1",
1564
            },
1576
            },
1565
        });
1577
        });
1566
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages/*", eholdings_package).as(
1578
        cy.intercept(
1567
            "get-eholdings-package"
1579
            "GET",
1568
        );
1580
            "/api/v1/erm/eholdings/local/packages/*",
1581
            eholdings_package
1582
        ).as("get-eholdings-package");
1569
1583
1570
        //Intercept vendors request
1584
        //Intercept vendors request
1571
        cy.intercept("GET", "/api/v1/acquisitions/vendors*", {
1585
        cy.intercept("GET", "/api/v1/acquisitions/vendors*", {
Lines 1615-1628 describe("Additional Fields operations", () => { Link Here
1615
        )
1629
        )
1616
            .parent()
1630
            .parent()
1617
            .children("input")
1631
            .children("input")
1618
            .should("have.value", eholdings_package.extended_attributes[2].value);
1632
            .should(
1633
                "have.value",
1634
                eholdings_package.extended_attributes[2].value
1635
            );
1619
1636
1620
        cy.get(
1637
        cy.get(
1621
            "#packages_add form #additional_fields label[for='additional_field_3']"
1638
            "#packages_add form #additional_fields label[for='additional_field_3']"
1622
        )
1639
        )
1623
            .parent()
1640
            .parent()
1624
            .children("input")
1641
            .children("input")
1625
            .should("have.value", eholdings_package.extended_attributes[3].value);
1642
            .should(
1643
                "have.value",
1644
                eholdings_package.extended_attributes[3].value
1645
            );
1626
1646
1627
        cy.get("#additional_fields #additional_field_4 .vs__selected").contains(
1647
        cy.get("#additional_fields #additional_field_4 .vs__selected").contains(
1628
            get_description_from_av_value(
1648
            get_description_from_av_value(
Lines 1659-1663 describe("Additional Fields operations", () => { Link Here
1659
            "#packages_add form #additional_fields label[for='additional_field_3']"
1679
            "#packages_add form #additional_fields label[for='additional_field_3']"
1660
        ).should("have.length", 2);
1680
        ).should("have.length", 2);
1661
    });
1681
    });
1662
1663
});
1682
});
1664
- 

Return to bug 37577