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

(-)a/installer/data/mysql/atomicupdate/bug_30708.pl (-1 / +2 lines)
Lines 97-106 return { Link Here
97
        unless ( TableExists('preservation_processing_attributes_items') ) {
97
        unless ( TableExists('preservation_processing_attributes_items') ) {
98
            $dbh->do(q{
98
            $dbh->do(q{
99
                CREATE TABLE `preservation_processing_attributes_items` (
99
                CREATE TABLE `preservation_processing_attributes_items` (
100
                  `processing_attribute_item_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
100
                  `processing_attribute_id` int(11) NOT NULL COMMENT 'link with preservation_processing_attributes',
101
                  `processing_attribute_id` int(11) NOT NULL COMMENT 'link with preservation_processing_attributes',
101
                  `train_item_id` int(11) NOT NULL COMMENT 'link with preservation_trains_items',
102
                  `train_item_id` int(11) NOT NULL COMMENT 'link with preservation_trains_items',
102
                  `value` varchar(255) NULL COMMENT 'value for this attribute',
103
                  `value` varchar(255) NULL COMMENT 'value for this attribute',
103
                  PRIMARY KEY (`processing_attribute_id`,`train_item_id`),
104
                  PRIMARY KEY (`processing_attribute_item_id`),
104
                  CONSTRAINT `preservation_processing_attributes_items_ibfk_1` FOREIGN KEY (`processing_attribute_id`) REFERENCES `preservation_processing_attributes` (`processing_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
105
                  CONSTRAINT `preservation_processing_attributes_items_ibfk_1` FOREIGN KEY (`processing_attribute_id`) REFERENCES `preservation_processing_attributes` (`processing_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
105
                  CONSTRAINT `preservation_processing_attributes_items_ibfk_2` FOREIGN KEY (`train_item_id`) REFERENCES `preservation_trains_items` (`train_item_id`) ON DELETE CASCADE ON UPDATE CASCADE
106
                  CONSTRAINT `preservation_processing_attributes_items_ibfk_2` FOREIGN KEY (`train_item_id`) REFERENCES `preservation_trains_items` (`train_item_id`) ON DELETE CASCADE ON UPDATE CASCADE
106
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
107
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/installer/data/mysql/kohastructure.sql (-1 / +2 lines)
Lines 4826-4835 DROP TABLE IF EXISTS `preservation_processing_attributes_items`; Link Here
4826
/*!40101 SET @saved_cs_client     = @@character_set_client */;
4826
/*!40101 SET @saved_cs_client     = @@character_set_client */;
4827
/*!40101 SET character_set_client = utf8 */;
4827
/*!40101 SET character_set_client = utf8 */;
4828
CREATE TABLE `preservation_processing_attributes_items` (
4828
CREATE TABLE `preservation_processing_attributes_items` (
4829
  `processing_attribute_item_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
4829
  `processing_attribute_id` int(11) NOT NULL COMMENT 'link with preservation_processing_attributes',
4830
  `processing_attribute_id` int(11) NOT NULL COMMENT 'link with preservation_processing_attributes',
4830
  `train_item_id` int(11) NOT NULL COMMENT 'link with preservation_trains_items',
4831
  `train_item_id` int(11) NOT NULL COMMENT 'link with preservation_trains_items',
4831
  `value` varchar(255) NULL COMMENT 'value for this attribute',
4832
  `value` varchar(255) NULL COMMENT 'value for this attribute',
4832
  PRIMARY KEY (`processing_attribute_id`,`train_item_id`),
4833
  PRIMARY KEY (`processing_attribute_item_id`),
4833
  CONSTRAINT `preservation_processing_attributes_items_ibfk_1` FOREIGN KEY (`processing_attribute_id`) REFERENCES `preservation_processing_attributes` (`processing_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4834
  CONSTRAINT `preservation_processing_attributes_items_ibfk_1` FOREIGN KEY (`processing_attribute_id`) REFERENCES `preservation_processing_attributes` (`processing_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4834
  CONSTRAINT `preservation_processing_attributes_items_ibfk_2` FOREIGN KEY (`train_item_id`) REFERENCES `preservation_trains_items` (`train_item_id`) ON DELETE CASCADE ON UPDATE CASCADE
4835
  CONSTRAINT `preservation_processing_attributes_items_ibfk_2` FOREIGN KEY (`train_item_id`) REFERENCES `preservation_trains_items` (`train_item_id`) ON DELETE CASCADE ON UPDATE CASCADE
4835
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4836
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsFormAddItem.vue (-18 / +60 lines)
Lines 60-65 Link Here
60
                                    v-model="attribute.value"
60
                                    v-model="attribute.value"
61
                                />
61
                                />
62
                            </span>
62
                            </span>
63
                            <a
64
                                v-if="
65
                                    attributes.length == counter + 1 ||
66
                                    attributes[counter + 1]
67
                                        .processing_attribute_id !=
68
                                        attribute.processing_attribute_id
69
                                "
70
                                class="btn btn-link"
71
                                @click="
72
                                    addAttribute(
73
                                        attribute.processing_attribute_id
74
                                    )
75
                                "
76
                                ><font-awesome-icon icon="plus" />
77
                                {{ $__("Add") }}</a
78
                            >
79
                            <a
80
                                v-else
81
                                class="btn btn-link"
82
                                @click="removeAttribute(counter)"
83
                                ><font-awesome-icon icon="minus" />
84
                                {{ $__("Remove") }}</a
85
                            >
63
                        </li>
86
                        </li>
64
                    </ol>
87
                    </ol>
65
                </fieldset>
88
                </fieldset>
Lines 238-265 export default { Link Here
238
                error => {}
261
                error => {}
239
            )
262
            )
240
            this.updateDefaultValues()
263
            this.updateDefaultValues()
241
            this.attributes = this.processing.attributes.map(attribute => {
264
            this.attributes = []
242
                let value = ""
265
            this.processing.attributes.forEach(attribute => {
266
                let values = []
243
                if (!apply_default_value) {
267
                if (!apply_default_value) {
244
                    let existing_attribute = this.train_item.attributes.find(
268
                    this.train_item.attributes
245
                        a =>
269
                        .filter(
246
                            a.processing_attribute_id ==
270
                            a =>
247
                            attribute.processing_attribute_id
271
                                a.processing_attribute_id ==
248
                    )
272
                                attribute.processing_attribute_id
249
                    if (existing_attribute) {
273
                        )
250
                        value = existing_attribute.value
274
                        .forEach(a => values.push(a.value))
251
                    }
252
                } else if (attribute.type == "db_column") {
275
                } else if (attribute.type == "db_column") {
253
                    value =
276
                    values.push(
254
                        this.default_values[attribute.processing_attribute_id]
277
                        this.default_values[attribute.processing_attribute_id]
278
                    )
279
                } else {
280
                    values.push("")
255
                }
281
                }
256
                return {
282
                values.forEach(value =>
257
                    processing_attribute_id: attribute.processing_attribute_id,
283
                    this.attributes.push({
258
                    name: attribute.name,
284
                        processing_attribute_id:
259
                    type: attribute.type,
285
                            attribute.processing_attribute_id,
260
                    option_source: attribute.option_source,
286
                        name: attribute.name,
261
                    value,
287
                        type: attribute.type,
262
                }
288
                        option_source: attribute.option_source,
289
                        value,
290
                    })
291
                )
263
            })
292
            })
264
            const client_av = APIClient.authorised_values
293
            const client_av = APIClient.authorised_values
265
            let av_cat_array = this.processing.attributes
294
            let av_cat_array = this.processing.attributes
Lines 280-285 export default { Link Here
280
                })
309
                })
281
                .then(() => this.loaded())
310
                .then(() => this.loaded())
282
        },
311
        },
312
        addAttribute(processing_attribute_id) {
313
            let last_index = this.attributes.findLastIndex(
314
                attribute =>
315
                    attribute.processing_attribute_id == processing_attribute_id
316
            )
317
            let new_attribute = (({ value, ...keepAttrs }) => keepAttrs)(
318
                this.attributes[last_index]
319
            )
320
            this.attributes.splice(last_index + 1, 0, new_attribute)
321
        },
322
        removeAttribute(counter) {
323
            this.attributes.splice(counter, 1)
324
        },
283
        onSubmit(e) {
325
        onSubmit(e) {
284
            e.preventDefault()
326
            e.preventDefault()
285
327
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue (-11 / +8 lines)
Lines 263-283 export default { Link Here
263
                            let item_row = {}
263
                            let item_row = {}
264
                            this.train.default_processing.attributes.forEach(
264
                            this.train.default_processing.attributes.forEach(
265
                                attribute => {
265
                                attribute => {
266
                                    let v = ""
266
                                    item_row[
267
                                    if (item.attributes.length >= 0) {
267
                                        attribute.processing_attribute_id
268
                                        let a = item.attributes.find(
268
                                    ] = item.attributes
269
                                        .filter(
269
                                            a =>
270
                                            a =>
270
                                                a.processing_attribute_id ==
271
                                                a.processing_attribute_id ==
271
                                                attribute.processing_attribute_id
272
                                                attribute.processing_attribute_id
272
                                        )
273
                                        )
273
                                        if (a) {
274
                                        .map(a => a.value)
274
                                            v = a.value
275
                                        }
276
                                    }
277
278
                                    item_row[
279
                                        attribute.processing_attribute_id
280
                                    ] = v
281
                                }
275
                                }
282
                            )
276
                            )
283
                            item_row.item = item
277
                            item_row.item = item
Lines 294-299 export default { Link Here
294
                                name: a.name,
288
                                name: a.name,
295
                                title: a.name,
289
                                title: a.name,
296
                                data: a.processing_attribute_id,
290
                                data: a.processing_attribute_id,
291
                                render: (data, type, row) => {
292
                                    return data.join("<br/>")
293
                                },
297
                            })
294
                            })
298
                        )
295
                        )
299
                        this.item_table.columns.push({
296
                        this.item_table.columns.push({
(-)a/t/cypress/integration/Preservation/Trains.ts (-1 / +6 lines)
Lines 99-104 function get_train_items() { Link Here
99
                processing_attributes[0].processing_attribute_id,
99
                processing_attributes[0].processing_attribute_id,
100
            value: "Argentina",
100
            value: "Argentina",
101
        },
101
        },
102
        {
103
            processing_attribute: processing_attributes[0],
104
            processing_attribute_id:
105
                processing_attributes[0].processing_attribute_id,
106
            value: "Paraguay",
107
        },
102
        {
108
        {
103
            processing_attribute: processing_attributes[1],
109
            processing_attribute: processing_attributes[1],
104
            processing_attribute_id:
110
            processing_attribute_id:
105
- 

Return to bug 30708