@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 CHANGED
@@ -3967,7 +3967,118 @@ var useCsvDownload = function useCsvDownload(_ref3) {
3967
3967
  };
3968
3968
  };
3969
3969
 
3970
- var _excluded$7 = ["itemType", "collectionType", "joinValue", "flat", "children"];
3970
+ function useCompoundMetadata(itemId, values, groups, groupFields, setGroupFields, onRefresh, onSuccess, onError) {
3971
+ var isFamily = function isFamily(el) {
3972
+ return el.hasMultipleChild;
3973
+ };
3974
+
3975
+ var groupFamily = groups.findIndex(isFamily);
3976
+ var tableColumns = groups[groupFamily].groups[0].fields.map(function (group) {
3977
+ return group;
3978
+ });
3979
+
3980
+ var onChange = function onChange(e, row, groupIndex, editIndex) {
3981
+ var value = e.target.value;
3982
+ var name = e.target.name;
3983
+ var newGroups = groupFields.map(function (group) {
3984
+ return group;
3985
+ });
3986
+ var newRows = newGroups[groupIndex].group.map(function (newRow, rowIndex) {
3987
+ if (rowIndex === editIndex) {
3988
+ return _objectSpread2(_objectSpread2({}, row), {}, _defineProperty({}, name, value));
3989
+ }
3990
+
3991
+ return newRow;
3992
+ });
3993
+ newGroups[groupIndex].group = newRows;
3994
+ setGroupFields(newGroups);
3995
+ };
3996
+
3997
+ var onSubmit = /*#__PURE__*/function () {
3998
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) {
3999
+ var groupNames, metadataDocument, newTimeSpan, uuid, newGroups;
4000
+ return regeneratorRuntime.wrap(function _callee$(_context) {
4001
+ while (1) {
4002
+ switch (_context.prev = _context.next) {
4003
+ case 0:
4004
+ groupNames = [];
4005
+ groups.forEach(function (group) {
4006
+ var newGroup = {};
4007
+ newGroup.parentGroup = group.name;
4008
+ newGroup.childGroup = group.groups[0].name;
4009
+ groupNames.push(newGroup);
4010
+ });
4011
+ metadataDocument = createMetadataType({
4012
+ group: data
4013
+ });
4014
+ newTimeSpan = metadataDocument.timespan;
4015
+ uuid = values.itemType.metadata.timespan[0].group[0].uuid;
4016
+ newGroups = [];
4017
+ newTimeSpan[0].group.forEach(function (group, index) {
4018
+ var newGroup = {
4019
+ group: []
4020
+ };
4021
+ newGroup.name = groupNames[index].parentGroup;
4022
+ newGroup.mode = 'add';
4023
+ group.group.forEach(function (subGroup) {
4024
+ var newSubGroup = subGroup;
4025
+ newSubGroup.name = groupNames[index].childGroup;
4026
+ newSubGroup.mode = 'add';
4027
+ newGroup.group.push(newSubGroup);
4028
+ });
4029
+ newGroups.push(newGroup);
4030
+ });
4031
+ newTimeSpan[0].group = newGroups;
4032
+ _context.prev = 8;
4033
+ _context.next = 11;
4034
+ return metadata.removeMetadata({
4035
+ metadataUuid: uuid
4036
+ });
4037
+
4038
+ case 11:
4039
+ _context.next = 13;
4040
+ return item.updateItemMetadata({
4041
+ itemId: itemId,
4042
+ metadataDocument: {
4043
+ timespan: newTimeSpan
4044
+ }
4045
+ });
4046
+
4047
+ case 13:
4048
+ _context.next = 15;
4049
+ return onRefresh();
4050
+
4051
+ case 15:
4052
+ onSuccess();
4053
+ _context.next = 21;
4054
+ break;
4055
+
4056
+ case 18:
4057
+ _context.prev = 18;
4058
+ _context.t0 = _context["catch"](8);
4059
+ onError(_context.t0);
4060
+
4061
+ case 21:
4062
+ case "end":
4063
+ return _context.stop();
4064
+ }
4065
+ }
4066
+ }, _callee, null, [[8, 18]]);
4067
+ }));
4068
+
4069
+ return function onSubmit(_x) {
4070
+ return _ref.apply(this, arguments);
4071
+ };
4072
+ }();
4073
+
4074
+ return {
4075
+ tableColumns: tableColumns,
4076
+ onChange: onChange,
4077
+ onSubmit: onSubmit
4078
+ };
4079
+ }
4080
+
4081
+ var _excluded$7 = ["itemType", "collectionType", "joinValue", "flat", "groupAsList", "children"];
3971
4082
  function MetadataType(_ref) {
3972
4083
  var itemType = _ref.itemType,
3973
4084
  collectionType = _ref.collectionType,
@@ -3975,6 +4086,8 @@ function MetadataType(_ref) {
3975
4086
  joinValue = _ref$joinValue === void 0 ? ',' : _ref$joinValue,
3976
4087
  _ref$flat = _ref.flat,
3977
4088
  flat = _ref$flat === void 0 ? true : _ref$flat,
4089
+ _ref$groupAsList = _ref.groupAsList,
4090
+ groupAsList = _ref$groupAsList === void 0 ? true : _ref$groupAsList,
3978
4091
  children = _ref.children,
3979
4092
  props = _objectWithoutProperties(_ref, _excluded$7);
3980
4093
 
@@ -3983,9 +4096,10 @@ function MetadataType(_ref) {
3983
4096
  var metadata = React.useMemo(function () {
3984
4097
  return parseMetadataType(metadataType, {
3985
4098
  joinValue: joinValue,
3986
- flat: flat
4099
+ flat: flat,
4100
+ groupAsList: groupAsList
3987
4101
  });
3988
- }, [flat, joinValue, metadataType]);
4102
+ }, [flat, groupAsList, joinValue, metadataType]);
3989
4103
 
3990
4104
  var cloneProps = _objectSpread2(_objectSpread2(_objectSpread2({}, props), metadata), {}, {
3991
4105
  itemType: itemType
@@ -5582,5 +5696,5 @@ var handleMoveEntity = function handleMoveEntity(_ref3) {
5582
5696
  }
5583
5697
  };
5584
5698
 
5585
- export { Auth, AuthContext, AuthProvider, BinContext, BinProvider, ComposeProviders, DropArea, ErrorBoundary, GetCollectionContent as GetCollection, GetFieldGroup, GetItem, GetJobs, HasRole, ListEntityAccess, MetadataType, RolesProvider, SearchCollection, SearchItem, SearchItemCollection, SettingsProvider, VidispineApi, compose, handleAddEntity, handleMoveEntity, handleRemoveEntity, useAddMetadataFieldAttributes, useApi, useAuthContext, useAutocomplete, useCollectionAutoPlay, useCsvDownload, useDocSearchAutocomplete, useEntityAccess, useGetCollection, useGetCollection$1 as useGetCollectionItem, useGetEntity, useGetFieldMetadataDataset, useGetItem, useGetSavedSearchFolders, useGroup, useHoverScrub, useInterval, useJobSearch, useListGroup, useListUser, useLocalStorage, useMouseDownPosition, useQueryInitialState, useRepresentativeItems, useRoles, useSavedSearch, useSearch, useSearchGroup, useSearchItem, useSearchUser, useSelected, useSettings, useSettingsActions, useTab, useThumbnailScrub, useUpdateEffect, useUpdateQueryState, useUploadFiles, useUser, withErrorBoundary };
5699
+ export { Auth, AuthContext, AuthProvider, BinContext, BinProvider, ComposeProviders, DropArea, ErrorBoundary, GetCollectionContent as GetCollection, GetFieldGroup, GetItem, GetJobs, HasRole, ListEntityAccess, MetadataType, RolesProvider, SearchCollection, SearchItem, SearchItemCollection, SettingsProvider, VidispineApi, compose, handleAddEntity, handleMoveEntity, handleRemoveEntity, useAddMetadataFieldAttributes, useApi, useAuthContext, useAutocomplete, useCollectionAutoPlay, useCompoundMetadata, useCsvDownload, useDocSearchAutocomplete, useEntityAccess, useGetCollection, useGetCollection$1 as useGetCollectionItem, useGetEntity, useGetFieldMetadataDataset, useGetItem, useGetSavedSearchFolders, useGroup, useHoverScrub, useInterval, useJobSearch, useListGroup, useListUser, useLocalStorage, useMouseDownPosition, useQueryInitialState, useRepresentativeItems, useRoles, useSavedSearch, useSearch, useSearchGroup, useSearchItem, useSearchUser, useSelected, useSettings, useSettingsActions, useTab, useThumbnailScrub, useUpdateEffect, useUpdateQueryState, useUploadFiles, useUser, withErrorBoundary };
5586
5700
  //# sourceMappingURL=index.es.js.map