@vidispine/vdt-react 21.4.0-pre.1 → 21.4.0-pre.2
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.
- package/dist/index.es.js +118 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +118 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -3974,7 +3974,118 @@ var useCsvDownload = function useCsvDownload(_ref3) {
|
|
|
3974
3974
|
};
|
|
3975
3975
|
};
|
|
3976
3976
|
|
|
3977
|
-
|
|
3977
|
+
function useCompoundMetadata(itemId, values, groups, groupFields, setGroupFields, onRefresh, onSuccess, onError) {
|
|
3978
|
+
var isFamily = function isFamily(el) {
|
|
3979
|
+
return el.hasMultipleChild;
|
|
3980
|
+
};
|
|
3981
|
+
|
|
3982
|
+
var groupFamily = groups.findIndex(isFamily);
|
|
3983
|
+
var tableColumns = groups[groupFamily].groups[0].fields.map(function (group) {
|
|
3984
|
+
return group;
|
|
3985
|
+
});
|
|
3986
|
+
|
|
3987
|
+
var onChange = function onChange(e, row, groupIndex, editIndex) {
|
|
3988
|
+
var value = e.target.value;
|
|
3989
|
+
var name = e.target.name;
|
|
3990
|
+
var newGroups = groupFields.map(function (group) {
|
|
3991
|
+
return group;
|
|
3992
|
+
});
|
|
3993
|
+
var newRows = newGroups[groupIndex].group.map(function (newRow, rowIndex) {
|
|
3994
|
+
if (rowIndex === editIndex) {
|
|
3995
|
+
return _objectSpread2(_objectSpread2({}, row), {}, _defineProperty({}, name, value));
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3998
|
+
return newRow;
|
|
3999
|
+
});
|
|
4000
|
+
newGroups[groupIndex].group = newRows;
|
|
4001
|
+
setGroupFields(newGroups);
|
|
4002
|
+
};
|
|
4003
|
+
|
|
4004
|
+
var onSubmit = /*#__PURE__*/function () {
|
|
4005
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) {
|
|
4006
|
+
var groupNames, metadataDocument, newTimeSpan, uuid, newGroups;
|
|
4007
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4008
|
+
while (1) {
|
|
4009
|
+
switch (_context.prev = _context.next) {
|
|
4010
|
+
case 0:
|
|
4011
|
+
groupNames = [];
|
|
4012
|
+
groups.forEach(function (group) {
|
|
4013
|
+
var newGroup = {};
|
|
4014
|
+
newGroup.parentGroup = group.name;
|
|
4015
|
+
newGroup.childGroup = group.groups[0].name;
|
|
4016
|
+
groupNames.push(newGroup);
|
|
4017
|
+
});
|
|
4018
|
+
metadataDocument = vdtJs.createMetadataType({
|
|
4019
|
+
group: data
|
|
4020
|
+
});
|
|
4021
|
+
newTimeSpan = metadataDocument.timespan;
|
|
4022
|
+
uuid = values.itemType.metadata.timespan[0].group[0].uuid;
|
|
4023
|
+
newGroups = [];
|
|
4024
|
+
newTimeSpan[0].group.forEach(function (group, index) {
|
|
4025
|
+
var newGroup = {
|
|
4026
|
+
group: []
|
|
4027
|
+
};
|
|
4028
|
+
newGroup.name = groupNames[index].parentGroup;
|
|
4029
|
+
newGroup.mode = 'add';
|
|
4030
|
+
group.group.forEach(function (subGroup) {
|
|
4031
|
+
var newSubGroup = subGroup;
|
|
4032
|
+
newSubGroup.name = groupNames[index].childGroup;
|
|
4033
|
+
newSubGroup.mode = 'add';
|
|
4034
|
+
newGroup.group.push(newSubGroup);
|
|
4035
|
+
});
|
|
4036
|
+
newGroups.push(newGroup);
|
|
4037
|
+
});
|
|
4038
|
+
newTimeSpan[0].group = newGroups;
|
|
4039
|
+
_context.prev = 8;
|
|
4040
|
+
_context.next = 11;
|
|
4041
|
+
return vdtApi.metadata.removeMetadata({
|
|
4042
|
+
metadataUuid: uuid
|
|
4043
|
+
});
|
|
4044
|
+
|
|
4045
|
+
case 11:
|
|
4046
|
+
_context.next = 13;
|
|
4047
|
+
return vdtApi.item.updateItemMetadata({
|
|
4048
|
+
itemId: itemId,
|
|
4049
|
+
metadataDocument: {
|
|
4050
|
+
timespan: newTimeSpan
|
|
4051
|
+
}
|
|
4052
|
+
});
|
|
4053
|
+
|
|
4054
|
+
case 13:
|
|
4055
|
+
_context.next = 15;
|
|
4056
|
+
return onRefresh();
|
|
4057
|
+
|
|
4058
|
+
case 15:
|
|
4059
|
+
onSuccess();
|
|
4060
|
+
_context.next = 21;
|
|
4061
|
+
break;
|
|
4062
|
+
|
|
4063
|
+
case 18:
|
|
4064
|
+
_context.prev = 18;
|
|
4065
|
+
_context.t0 = _context["catch"](8);
|
|
4066
|
+
onError(_context.t0);
|
|
4067
|
+
|
|
4068
|
+
case 21:
|
|
4069
|
+
case "end":
|
|
4070
|
+
return _context.stop();
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
}, _callee, null, [[8, 18]]);
|
|
4074
|
+
}));
|
|
4075
|
+
|
|
4076
|
+
return function onSubmit(_x) {
|
|
4077
|
+
return _ref.apply(this, arguments);
|
|
4078
|
+
};
|
|
4079
|
+
}();
|
|
4080
|
+
|
|
4081
|
+
return {
|
|
4082
|
+
tableColumns: tableColumns,
|
|
4083
|
+
onChange: onChange,
|
|
4084
|
+
onSubmit: onSubmit
|
|
4085
|
+
};
|
|
4086
|
+
}
|
|
4087
|
+
|
|
4088
|
+
var _excluded$7 = ["itemType", "collectionType", "joinValue", "flat", "groupAsList", "children"];
|
|
3978
4089
|
function MetadataType(_ref) {
|
|
3979
4090
|
var itemType = _ref.itemType,
|
|
3980
4091
|
collectionType = _ref.collectionType,
|
|
@@ -3982,6 +4093,8 @@ function MetadataType(_ref) {
|
|
|
3982
4093
|
joinValue = _ref$joinValue === void 0 ? ',' : _ref$joinValue,
|
|
3983
4094
|
_ref$flat = _ref.flat,
|
|
3984
4095
|
flat = _ref$flat === void 0 ? true : _ref$flat,
|
|
4096
|
+
_ref$groupAsList = _ref.groupAsList,
|
|
4097
|
+
groupAsList = _ref$groupAsList === void 0 ? true : _ref$groupAsList,
|
|
3985
4098
|
children = _ref.children,
|
|
3986
4099
|
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
3987
4100
|
|
|
@@ -3990,9 +4103,10 @@ function MetadataType(_ref) {
|
|
|
3990
4103
|
var metadata = React__default.useMemo(function () {
|
|
3991
4104
|
return vdtJs.parseMetadataType(metadataType, {
|
|
3992
4105
|
joinValue: joinValue,
|
|
3993
|
-
flat: flat
|
|
4106
|
+
flat: flat,
|
|
4107
|
+
groupAsList: groupAsList
|
|
3994
4108
|
});
|
|
3995
|
-
}, [flat, joinValue, metadataType]);
|
|
4109
|
+
}, [flat, groupAsList, joinValue, metadataType]);
|
|
3996
4110
|
|
|
3997
4111
|
var cloneProps = _objectSpread2(_objectSpread2(_objectSpread2({}, props), metadata), {}, {
|
|
3998
4112
|
itemType: itemType
|
|
@@ -5619,6 +5733,7 @@ exports.useApi = useApi;
|
|
|
5619
5733
|
exports.useAuthContext = useAuthContext;
|
|
5620
5734
|
exports.useAutocomplete = useAutocomplete;
|
|
5621
5735
|
exports.useCollectionAutoPlay = useCollectionAutoPlay;
|
|
5736
|
+
exports.useCompoundMetadata = useCompoundMetadata;
|
|
5622
5737
|
exports.useCsvDownload = useCsvDownload;
|
|
5623
5738
|
exports.useDocSearchAutocomplete = useDocSearchAutocomplete;
|
|
5624
5739
|
exports.useEntityAccess = useEntityAccess;
|