@seidhr/sanity-plugin-muna-schemas
Version:
Muna or ᛗᚢᚾᚨ means remember in norse. Muna is a schema for the Sanity Studio that enables detailed descriptions of cultural heritage objects and knowledge about their contexts as well as pages about them (or anything else really.)
125 lines (114 loc) • 4.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _gi = require("react-icons/gi");
var _coalesceLabel = require("../../../../helpers/coalesceLabel");
var _datatype = require("../../../properties/datatype");
var _object = require("../../../properties/object");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _default = {
name: 'Production',
type: 'document',
title: 'Production',
titleEN: 'Produksjon',
icon: _gi.GiFactory,
fieldsets: _coalesceLabel.defaultFieldsets,
fields: [_datatype.featured, {
name: 'consistsOf',
title: 'Underaktiviteter',
titleEN: 'Sub activities',
description: 'OBS! Det er mulig å nøste flere produksjoner under hverandre per i dag, men bare bruk ett nivå!',
type: 'array',
of: [{
type: 'Production'
}],
options: {
semanticSanity: {
'@container': '@set',
'@type': '@id'
}
},
validation: Rule => Rule.min(2).warning('Prodcution with multiple actors must have at least 2 actors. If there is only one actor do not use "sub-activities"')
}, {
name: 'hasType',
title: 'Klassifisert som',
titleEN: 'Classified as',
type: 'array',
of: [{
type: 'reference',
to: [{
type: 'ActivityType'
}]
}],
options: {
semanticSanity: {
'@container': '@set',
'@type': '@id'
}
}
}, _objectSpread(_objectSpread({}, _object.contributionAssignedBy), {}, {
hidden: _ref => {
var value = _ref.value,
parent = _ref.parent;
return !value && (parent === null || parent === void 0 ? void 0 : parent.consistsOf);
}
}), _objectSpread({}, _object.timespanSingleton), _objectSpread({}, _object.tookPlaceAt), _objectSpread({}, _object.referredToBy), {
name: 'hasModified',
title: 'Har modifisert',
titleEN: 'Has modified',
description: 'A production can modify an existing object',
type: 'array',
of: [{
type: 'reference',
to: [{
type: 'HumanMadeObject'
}]
}],
options: {
semanticSanity: {
'@container': '@set',
'@type': '@id'
}
}
}, _objectSpread(_objectSpread({}, _object.usedGeneralTechnique), {}, {
hidden: _ref2 => {
var value = _ref2.value,
parent = _ref2.parent;
return !value && (parent === null || parent === void 0 ? void 0 : parent.consistsOf);
}
}), _objectSpread(_objectSpread({}, _object.usedSpecificTechnique), {}, {
hidden: _ref3 => {
var value = _ref3.value,
parent = _ref3.parent;
return !value && (parent === null || parent === void 0 ? void 0 : parent.consistsOf);
}
})],
preview: {
select: {
contributor: 'contributionAssignedBy.0.assignedActor.label',
contributorName: 'contributionAssignedBy.0.usedName.content',
mainRole: 'contributionAssignedBy.0.assignedRole.0.label',
consistsOf: 'consistsOf',
edtf: 'timespan.edtf'
},
prepare(selection) {
var contributor = selection.contributor,
contributorName = selection.contributorName,
mainRole = selection.mainRole,
consistsOf = selection.consistsOf,
edtf = selection.edtf;
var title = "Production, by ".concat((0, _coalesceLabel.coalesceLabel)(contributor) || contributorName || 'unknown', " ").concat(mainRole ? "(".concat((0, _coalesceLabel.coalesceLabel)(mainRole), ")") : '');
var multiPartProduction = consistsOf ? "".concat(consistsOf.length, " participants in the production") : null;
return {
title: multiPartProduction !== null && multiPartProduction !== void 0 ? multiPartProduction : title,
subtitle: edtf
};
}
}
};
exports.default = _default;
//# sourceMappingURL=Production.js.map