@bigbinary/neeto-fields-frontend 1.1.7 → 1.1.9

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.cjs.js CHANGED
@@ -5285,7 +5285,7 @@ var titles = {
5285
5285
  field_other: "Fields",
5286
5286
  addField: "Add new field",
5287
5287
  editField: "Edit field",
5288
- deleteField: "Delete field ?",
5288
+ deleteField: "Delete field?",
5289
5289
  fieldName: "Field name",
5290
5290
  fieldKind: "Field type",
5291
5291
  required: "Required",
@@ -5342,7 +5342,8 @@ var fields = {
5342
5342
  };
5343
5343
  var messages = {
5344
5344
  noFields: "There are no {{title}} to show",
5345
- confirmDelete: "Are you sure want to delete the field? This action cannot be undone.",
5345
+ confirmDelete: "You are permanently deleting the field <strong>{{name}}</strong>. This action can't be undone.",
5346
+ confirmDeleteWithCount: "You are permanently deleting the field <strong>{{name}}</strong> which holds values for <strong>{{count}} {{resource}}</strong>. The values will be lost on deleting the field. This action can't be undone.",
5346
5347
  manageFieldFor: "Manage fields for {{resource}}",
5347
5348
  manageTitleForResource: "Manage {{title}} for {{resource}}",
5348
5349
  titleForResource: "{{title}} for {{resource}}",
@@ -6402,6 +6403,7 @@ var FIELDS_URL = "".concat(NEETO_FIELDS_URL, "/fields");
6402
6403
  var FIELD_VALUES_URL = "".concat(NEETO_FIELDS_URL, "/field_values");
6403
6404
  var FIELD_VALUE_URL = "".concat(NEETO_FIELDS_URL, "/field_values/:fieldValueId");
6404
6405
  var FIELD_URL = "".concat(NEETO_FIELDS_URL, "/fields/:fieldId");
6406
+ var DEPENDENCIES_URL = "".concat(NEETO_FIELDS_URL, "/fields/:fieldId/dependencies");
6405
6407
  var FIELDS_REORDER_URL = "".concat(FIELDS_URL, "/reorder");
6406
6408
  var CONFIGS_URL = "".concat(NEETO_FIELDS_URL, "/configs");
6407
6409
  var SINGULAR = {
@@ -6431,6 +6433,11 @@ var fieldUrl = function fieldUrl(fieldId) {
6431
6433
  fieldId: fieldId
6432
6434
  });
6433
6435
  };
6436
+ var dependenciesUrl = function dependenciesUrl(fieldId) {
6437
+ return utils.buildUrl(DEPENDENCIES_URL, {
6438
+ fieldId: fieldId
6439
+ });
6440
+ };
6434
6441
  var fetch$1 = function fetch(_ref) {
6435
6442
  var resourceType = _ref.resourceType,
6436
6443
  ownerId = _ref.ownerId,
@@ -6474,25 +6481,37 @@ var update$1 = function update(_ref4) {
6474
6481
  var reorder = function reorder(payload) {
6475
6482
  return axios__default["default"].patch(FIELDS_REORDER_URL, payload);
6476
6483
  };
6484
+ var dependencies = function dependencies(_ref5) {
6485
+ var fieldId = _ref5.fieldId,
6486
+ ownerId = _ref5.ownerId;
6487
+ return axios__default["default"].get(dependenciesUrl(fieldId), {
6488
+ params: {
6489
+ ownerId: ownerId
6490
+ }
6491
+ });
6492
+ };
6477
6493
  var fieldsApi = {
6478
6494
  fetch: fetch$1,
6479
6495
  create: create$1,
6480
6496
  show: show,
6481
6497
  destroy: destroy$1,
6482
6498
  update: update$1,
6483
- reorder: reorder
6499
+ reorder: reorder,
6500
+ dependencies: dependencies
6484
6501
  };
6485
6502
 
6486
6503
  var QUERY_KEYS = {
6487
6504
  FIELDS: "fields",
6488
6505
  FIELD_VALUES: "field_values",
6489
- CONFIGS: "configurations"
6506
+ CONFIGS: "configurations",
6507
+ DEPENDENCIES: "dependencies"
6490
6508
  };
6491
6509
  var DEFAULT_STALE_TIME = 3600000; // 1 hour
6492
6510
 
6493
6511
  function ownKeys$8(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; }
6494
6512
  function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6495
- var FIELDS = QUERY_KEYS.FIELDS;
6513
+ var FIELDS = QUERY_KEYS.FIELDS,
6514
+ DEPENDENCIES = QUERY_KEYS.DEPENDENCIES;
6496
6515
  var useFetchFields = function useFetchFields(_ref, options) {
6497
6516
  var resourceType = _ref.resourceType,
6498
6517
  ownerId = _ref.ownerId,
@@ -6535,6 +6554,16 @@ var useShowField = function useShowField(_ref2, options) {
6535
6554
  });
6536
6555
  }, options);
6537
6556
  };
6557
+ var useFetchDependencies = function useFetchDependencies(_ref3, options) {
6558
+ var fieldId = _ref3.fieldId,
6559
+ ownerId = _ref3.ownerId;
6560
+ return reactQuery.useQuery([DEPENDENCIES, fieldId], function () {
6561
+ return fieldsApi.dependencies({
6562
+ fieldId: fieldId,
6563
+ ownerId: ownerId
6564
+ });
6565
+ }, options);
6566
+ };
6538
6567
  var useUpdateField = function useUpdateField(options) {
6539
6568
  var queryClient = reactQuery.useQueryClient();
6540
6569
  return reactQuery.useMutation(fieldsApi.update, _objectSpread$8(_objectSpread$8({}, options), {}, {
@@ -6640,7 +6669,22 @@ var renderFormFooter = function renderFormFooter(_ref3) {
6640
6669
  };
6641
6670
 
6642
6671
  var regexValidationSchema = yup__namespace.object().shape({
6643
- condition: yup__namespace.string().required(t$1("validations.regexConditionIsRequired")).matches(/^\/.*\/[igmsyu]*$/, t$1("validations.invalidRegexPattern")),
6672
+ condition: yup__namespace.string().required(t$1("validations.regexConditionIsRequired")).matches(/^\/.*\/[igmsyu]*$/, t$1("validations.invalidRegexPattern")).test({
6673
+ name: "regex",
6674
+ message: t$1("validations.invalidRegexPattern") || "",
6675
+ test: function test(value) {
6676
+ try {
6677
+ var lastIndex = value.lastIndexOf("/");
6678
+ var condition = value.substring(1, lastIndex);
6679
+ // Evaluating the regex to check if it is valid
6680
+ new RegExp(condition);
6681
+ "".search(condition);
6682
+ return true;
6683
+ } catch (_unused) {
6684
+ return false;
6685
+ }
6686
+ }
6687
+ }),
6644
6688
  helpMessage: yup__namespace.string().required(t$1("validations.regexHelpMessageIsRequired"))
6645
6689
  });
6646
6690
  var dropDownOptionsValidationSchema = yup__namespace.array().of(yup__namespace.object().shape({
@@ -7045,6 +7089,517 @@ var FieldsPane = function FieldsPane(_ref) {
7045
7089
  }, props)));
7046
7090
  };
7047
7091
 
7092
+ function commonjsRequire(path) {
7093
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
7094
+ }
7095
+
7096
+ var pluralize$1 = {exports: {}};
7097
+
7098
+ /* global define */
7099
+ pluralize$1.exports;
7100
+
7101
+ (function (module, exports) {
7102
+ (function (root, pluralize) {
7103
+ /* istanbul ignore else */
7104
+ if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
7105
+ // Node.
7106
+ module.exports = pluralize();
7107
+ } else {
7108
+ // Browser global.
7109
+ root.pluralize = pluralize();
7110
+ }
7111
+ })(commonjsGlobal, function () {
7112
+ // Rule storage - pluralize and singularize need to be run sequentially,
7113
+ // while other rules can be optimized using an object for instant lookups.
7114
+ var pluralRules = [];
7115
+ var singularRules = [];
7116
+ var uncountables = {};
7117
+ var irregularPlurals = {};
7118
+ var irregularSingles = {};
7119
+
7120
+ /**
7121
+ * Sanitize a pluralization rule to a usable regular expression.
7122
+ *
7123
+ * @param {(RegExp|string)} rule
7124
+ * @return {RegExp}
7125
+ */
7126
+ function sanitizeRule (rule) {
7127
+ if (typeof rule === 'string') {
7128
+ return new RegExp('^' + rule + '$', 'i');
7129
+ }
7130
+
7131
+ return rule;
7132
+ }
7133
+
7134
+ /**
7135
+ * Pass in a word token to produce a function that can replicate the case on
7136
+ * another word.
7137
+ *
7138
+ * @param {string} word
7139
+ * @param {string} token
7140
+ * @return {Function}
7141
+ */
7142
+ function restoreCase (word, token) {
7143
+ // Tokens are an exact match.
7144
+ if (word === token) return token;
7145
+
7146
+ // Lower cased words. E.g. "hello".
7147
+ if (word === word.toLowerCase()) return token.toLowerCase();
7148
+
7149
+ // Upper cased words. E.g. "WHISKY".
7150
+ if (word === word.toUpperCase()) return token.toUpperCase();
7151
+
7152
+ // Title cased words. E.g. "Title".
7153
+ if (word[0] === word[0].toUpperCase()) {
7154
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
7155
+ }
7156
+
7157
+ // Lower cased words. E.g. "test".
7158
+ return token.toLowerCase();
7159
+ }
7160
+
7161
+ /**
7162
+ * Interpolate a regexp string.
7163
+ *
7164
+ * @param {string} str
7165
+ * @param {Array} args
7166
+ * @return {string}
7167
+ */
7168
+ function interpolate (str, args) {
7169
+ return str.replace(/\$(\d{1,2})/g, function (match, index) {
7170
+ return args[index] || '';
7171
+ });
7172
+ }
7173
+
7174
+ /**
7175
+ * Replace a word using a rule.
7176
+ *
7177
+ * @param {string} word
7178
+ * @param {Array} rule
7179
+ * @return {string}
7180
+ */
7181
+ function replace (word, rule) {
7182
+ return word.replace(rule[0], function (match, index) {
7183
+ var result = interpolate(rule[1], arguments);
7184
+
7185
+ if (match === '') {
7186
+ return restoreCase(word[index - 1], result);
7187
+ }
7188
+
7189
+ return restoreCase(match, result);
7190
+ });
7191
+ }
7192
+
7193
+ /**
7194
+ * Sanitize a word by passing in the word and sanitization rules.
7195
+ *
7196
+ * @param {string} token
7197
+ * @param {string} word
7198
+ * @param {Array} rules
7199
+ * @return {string}
7200
+ */
7201
+ function sanitizeWord (token, word, rules) {
7202
+ // Empty string or doesn't need fixing.
7203
+ if (!token.length || uncountables.hasOwnProperty(token)) {
7204
+ return word;
7205
+ }
7206
+
7207
+ var len = rules.length;
7208
+
7209
+ // Iterate over the sanitization rules and use the first one to match.
7210
+ while (len--) {
7211
+ var rule = rules[len];
7212
+
7213
+ if (rule[0].test(word)) return replace(word, rule);
7214
+ }
7215
+
7216
+ return word;
7217
+ }
7218
+
7219
+ /**
7220
+ * Replace a word with the updated word.
7221
+ *
7222
+ * @param {Object} replaceMap
7223
+ * @param {Object} keepMap
7224
+ * @param {Array} rules
7225
+ * @return {Function}
7226
+ */
7227
+ function replaceWord (replaceMap, keepMap, rules) {
7228
+ return function (word) {
7229
+ // Get the correct token and case restoration functions.
7230
+ var token = word.toLowerCase();
7231
+
7232
+ // Check against the keep object map.
7233
+ if (keepMap.hasOwnProperty(token)) {
7234
+ return restoreCase(word, token);
7235
+ }
7236
+
7237
+ // Check against the replacement map for a direct word replacement.
7238
+ if (replaceMap.hasOwnProperty(token)) {
7239
+ return restoreCase(word, replaceMap[token]);
7240
+ }
7241
+
7242
+ // Run all the rules against the word.
7243
+ return sanitizeWord(token, word, rules);
7244
+ };
7245
+ }
7246
+
7247
+ /**
7248
+ * Check if a word is part of the map.
7249
+ */
7250
+ function checkWord (replaceMap, keepMap, rules, bool) {
7251
+ return function (word) {
7252
+ var token = word.toLowerCase();
7253
+
7254
+ if (keepMap.hasOwnProperty(token)) return true;
7255
+ if (replaceMap.hasOwnProperty(token)) return false;
7256
+
7257
+ return sanitizeWord(token, token, rules) === token;
7258
+ };
7259
+ }
7260
+
7261
+ /**
7262
+ * Pluralize or singularize a word based on the passed in count.
7263
+ *
7264
+ * @param {string} word The word to pluralize
7265
+ * @param {number} count How many of the word exist
7266
+ * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)
7267
+ * @return {string}
7268
+ */
7269
+ function pluralize (word, count, inclusive) {
7270
+ var pluralized = count === 1
7271
+ ? pluralize.singular(word) : pluralize.plural(word);
7272
+
7273
+ return (inclusive ? count + ' ' : '') + pluralized;
7274
+ }
7275
+
7276
+ /**
7277
+ * Pluralize a word.
7278
+ *
7279
+ * @type {Function}
7280
+ */
7281
+ pluralize.plural = replaceWord(
7282
+ irregularSingles, irregularPlurals, pluralRules
7283
+ );
7284
+
7285
+ /**
7286
+ * Check if a word is plural.
7287
+ *
7288
+ * @type {Function}
7289
+ */
7290
+ pluralize.isPlural = checkWord(
7291
+ irregularSingles, irregularPlurals, pluralRules
7292
+ );
7293
+
7294
+ /**
7295
+ * Singularize a word.
7296
+ *
7297
+ * @type {Function}
7298
+ */
7299
+ pluralize.singular = replaceWord(
7300
+ irregularPlurals, irregularSingles, singularRules
7301
+ );
7302
+
7303
+ /**
7304
+ * Check if a word is singular.
7305
+ *
7306
+ * @type {Function}
7307
+ */
7308
+ pluralize.isSingular = checkWord(
7309
+ irregularPlurals, irregularSingles, singularRules
7310
+ );
7311
+
7312
+ /**
7313
+ * Add a pluralization rule to the collection.
7314
+ *
7315
+ * @param {(string|RegExp)} rule
7316
+ * @param {string} replacement
7317
+ */
7318
+ pluralize.addPluralRule = function (rule, replacement) {
7319
+ pluralRules.push([sanitizeRule(rule), replacement]);
7320
+ };
7321
+
7322
+ /**
7323
+ * Add a singularization rule to the collection.
7324
+ *
7325
+ * @param {(string|RegExp)} rule
7326
+ * @param {string} replacement
7327
+ */
7328
+ pluralize.addSingularRule = function (rule, replacement) {
7329
+ singularRules.push([sanitizeRule(rule), replacement]);
7330
+ };
7331
+
7332
+ /**
7333
+ * Add an uncountable word rule.
7334
+ *
7335
+ * @param {(string|RegExp)} word
7336
+ */
7337
+ pluralize.addUncountableRule = function (word) {
7338
+ if (typeof word === 'string') {
7339
+ uncountables[word.toLowerCase()] = true;
7340
+ return;
7341
+ }
7342
+
7343
+ // Set singular and plural references for the word.
7344
+ pluralize.addPluralRule(word, '$0');
7345
+ pluralize.addSingularRule(word, '$0');
7346
+ };
7347
+
7348
+ /**
7349
+ * Add an irregular word definition.
7350
+ *
7351
+ * @param {string} single
7352
+ * @param {string} plural
7353
+ */
7354
+ pluralize.addIrregularRule = function (single, plural) {
7355
+ plural = plural.toLowerCase();
7356
+ single = single.toLowerCase();
7357
+
7358
+ irregularSingles[single] = plural;
7359
+ irregularPlurals[plural] = single;
7360
+ };
7361
+
7362
+ /**
7363
+ * Irregular rules.
7364
+ */
7365
+ [
7366
+ // Pronouns.
7367
+ ['I', 'we'],
7368
+ ['me', 'us'],
7369
+ ['he', 'they'],
7370
+ ['she', 'they'],
7371
+ ['them', 'them'],
7372
+ ['myself', 'ourselves'],
7373
+ ['yourself', 'yourselves'],
7374
+ ['itself', 'themselves'],
7375
+ ['herself', 'themselves'],
7376
+ ['himself', 'themselves'],
7377
+ ['themself', 'themselves'],
7378
+ ['is', 'are'],
7379
+ ['was', 'were'],
7380
+ ['has', 'have'],
7381
+ ['this', 'these'],
7382
+ ['that', 'those'],
7383
+ // Words ending in with a consonant and `o`.
7384
+ ['echo', 'echoes'],
7385
+ ['dingo', 'dingoes'],
7386
+ ['volcano', 'volcanoes'],
7387
+ ['tornado', 'tornadoes'],
7388
+ ['torpedo', 'torpedoes'],
7389
+ // Ends with `us`.
7390
+ ['genus', 'genera'],
7391
+ ['viscus', 'viscera'],
7392
+ // Ends with `ma`.
7393
+ ['stigma', 'stigmata'],
7394
+ ['stoma', 'stomata'],
7395
+ ['dogma', 'dogmata'],
7396
+ ['lemma', 'lemmata'],
7397
+ ['schema', 'schemata'],
7398
+ ['anathema', 'anathemata'],
7399
+ // Other irregular rules.
7400
+ ['ox', 'oxen'],
7401
+ ['axe', 'axes'],
7402
+ ['die', 'dice'],
7403
+ ['yes', 'yeses'],
7404
+ ['foot', 'feet'],
7405
+ ['eave', 'eaves'],
7406
+ ['goose', 'geese'],
7407
+ ['tooth', 'teeth'],
7408
+ ['quiz', 'quizzes'],
7409
+ ['human', 'humans'],
7410
+ ['proof', 'proofs'],
7411
+ ['carve', 'carves'],
7412
+ ['valve', 'valves'],
7413
+ ['looey', 'looies'],
7414
+ ['thief', 'thieves'],
7415
+ ['groove', 'grooves'],
7416
+ ['pickaxe', 'pickaxes'],
7417
+ ['passerby', 'passersby']
7418
+ ].forEach(function (rule) {
7419
+ return pluralize.addIrregularRule(rule[0], rule[1]);
7420
+ });
7421
+
7422
+ /**
7423
+ * Pluralization rules.
7424
+ */
7425
+ [
7426
+ [/s?$/i, 's'],
7427
+ [/[^\u0000-\u007F]$/i, '$0'],
7428
+ [/([^aeiou]ese)$/i, '$1'],
7429
+ [/(ax|test)is$/i, '$1es'],
7430
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'],
7431
+ [/(e[mn]u)s?$/i, '$1s'],
7432
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'],
7433
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'],
7434
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],
7435
+ [/(seraph|cherub)(?:im)?$/i, '$1im'],
7436
+ [/(her|at|gr)o$/i, '$1oes'],
7437
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'],
7438
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'],
7439
+ [/sis$/i, 'ses'],
7440
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'],
7441
+ [/([^aeiouy]|qu)y$/i, '$1ies'],
7442
+ [/([^ch][ieo][ln])ey$/i, '$1ies'],
7443
+ [/(x|ch|ss|sh|zz)$/i, '$1es'],
7444
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],
7445
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'],
7446
+ [/(pe)(?:rson|ople)$/i, '$1ople'],
7447
+ [/(child)(?:ren)?$/i, '$1ren'],
7448
+ [/eaux$/i, '$0'],
7449
+ [/m[ae]n$/i, 'men'],
7450
+ ['thou', 'you']
7451
+ ].forEach(function (rule) {
7452
+ return pluralize.addPluralRule(rule[0], rule[1]);
7453
+ });
7454
+
7455
+ /**
7456
+ * Singularization rules.
7457
+ */
7458
+ [
7459
+ [/s$/i, ''],
7460
+ [/(ss)$/i, '$1'],
7461
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'],
7462
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'],
7463
+ [/ies$/i, 'y'],
7464
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'],
7465
+ [/\b(mon|smil)ies$/i, '$1ey'],
7466
+ [/\b((?:tit)?m|l)ice$/i, '$1ouse'],
7467
+ [/(seraph|cherub)im$/i, '$1'],
7468
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'],
7469
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'],
7470
+ [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],
7471
+ [/(test)(?:is|es)$/i, '$1is'],
7472
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'],
7473
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'],
7474
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'],
7475
+ [/(alumn|alg|vertebr)ae$/i, '$1a'],
7476
+ [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'],
7477
+ [/(matr|append)ices$/i, '$1ix'],
7478
+ [/(pe)(rson|ople)$/i, '$1rson'],
7479
+ [/(child)ren$/i, '$1'],
7480
+ [/(eau)x?$/i, '$1'],
7481
+ [/men$/i, 'man']
7482
+ ].forEach(function (rule) {
7483
+ return pluralize.addSingularRule(rule[0], rule[1]);
7484
+ });
7485
+
7486
+ /**
7487
+ * Uncountable rules.
7488
+ */
7489
+ [
7490
+ // Singular words with no plurals.
7491
+ 'adulthood',
7492
+ 'advice',
7493
+ 'agenda',
7494
+ 'aid',
7495
+ 'aircraft',
7496
+ 'alcohol',
7497
+ 'ammo',
7498
+ 'analytics',
7499
+ 'anime',
7500
+ 'athletics',
7501
+ 'audio',
7502
+ 'bison',
7503
+ 'blood',
7504
+ 'bream',
7505
+ 'buffalo',
7506
+ 'butter',
7507
+ 'carp',
7508
+ 'cash',
7509
+ 'chassis',
7510
+ 'chess',
7511
+ 'clothing',
7512
+ 'cod',
7513
+ 'commerce',
7514
+ 'cooperation',
7515
+ 'corps',
7516
+ 'debris',
7517
+ 'diabetes',
7518
+ 'digestion',
7519
+ 'elk',
7520
+ 'energy',
7521
+ 'equipment',
7522
+ 'excretion',
7523
+ 'expertise',
7524
+ 'firmware',
7525
+ 'flounder',
7526
+ 'fun',
7527
+ 'gallows',
7528
+ 'garbage',
7529
+ 'graffiti',
7530
+ 'hardware',
7531
+ 'headquarters',
7532
+ 'health',
7533
+ 'herpes',
7534
+ 'highjinks',
7535
+ 'homework',
7536
+ 'housework',
7537
+ 'information',
7538
+ 'jeans',
7539
+ 'justice',
7540
+ 'kudos',
7541
+ 'labour',
7542
+ 'literature',
7543
+ 'machinery',
7544
+ 'mackerel',
7545
+ 'mail',
7546
+ 'media',
7547
+ 'mews',
7548
+ 'moose',
7549
+ 'music',
7550
+ 'mud',
7551
+ 'manga',
7552
+ 'news',
7553
+ 'only',
7554
+ 'personnel',
7555
+ 'pike',
7556
+ 'plankton',
7557
+ 'pliers',
7558
+ 'police',
7559
+ 'pollution',
7560
+ 'premises',
7561
+ 'rain',
7562
+ 'research',
7563
+ 'rice',
7564
+ 'salmon',
7565
+ 'scissors',
7566
+ 'series',
7567
+ 'sewage',
7568
+ 'shambles',
7569
+ 'shrimp',
7570
+ 'software',
7571
+ 'species',
7572
+ 'staff',
7573
+ 'swine',
7574
+ 'tennis',
7575
+ 'traffic',
7576
+ 'transportation',
7577
+ 'trout',
7578
+ 'tuna',
7579
+ 'wealth',
7580
+ 'welfare',
7581
+ 'whiting',
7582
+ 'wildebeest',
7583
+ 'wildlife',
7584
+ 'you',
7585
+ /pok[eé]mon$/i,
7586
+ // Regexes.
7587
+ /[^aeiou]ese$/i, // "chinese", "japanese"
7588
+ /deer$/i, // "deer", "reindeer"
7589
+ /fish$/i, // "fish", "blowfish", "angelfish"
7590
+ /measles$/i,
7591
+ /o[iu]s$/i, // "carnivorous"
7592
+ /pox$/i, // "chickpox", "smallpox"
7593
+ /sheep$/i
7594
+ ].forEach(pluralize.addUncountableRule);
7595
+
7596
+ return pluralize;
7597
+ });
7598
+ } (pluralize$1, pluralize$1.exports));
7599
+
7600
+ var pluralizeExports = pluralize$1.exports;
7601
+ var pluralize = /*@__PURE__*/getDefaultExportFromCjs(pluralizeExports);
7602
+
7048
7603
  var Menu = neetoui.Dropdown.Menu,
7049
7604
  MenuItem = neetoui.Dropdown.MenuItem;
7050
7605
  var buildDefaultColumns = function buildDefaultColumns(_ref) {
@@ -7166,32 +7721,38 @@ var renderMenuBarFilters = function renderMenuBarFilters(_ref3) {
7166
7721
  })
7167
7722
  }));
7168
7723
  };
7169
- var getDashBoardTitle = function getDashBoardTitle(_ref4) {
7170
- var _findBy;
7724
+ var getResourceName = function getResourceName(_ref4) {
7171
7725
  var isOwnerBased = _ref4.isOwnerBased,
7172
7726
  owners = _ref4.owners,
7173
7727
  selectedVal = _ref4.selectedVal,
7174
- nameAliases = _ref4.nameAliases,
7175
- isSingleResource = _ref4.isSingleResource,
7176
- showStateFilter = _ref4.showStateFilter,
7177
- selectedState = _ref4.selectedState,
7178
- title = _ref4.title;
7179
- var resource = isOwnerBased ? (_findBy = pure.findBy({
7180
- id: selectedVal
7181
- }, owners)) === null || _findBy === void 0 ? void 0 : _findBy.name : nameAliases[selectedVal] || selectedVal;
7728
+ nameAliases = _ref4.nameAliases;
7729
+ if (isOwnerBased) {
7730
+ var _findBy;
7731
+ return (_findBy = pure.findBy({
7732
+ id: selectedVal
7733
+ }, owners)) === null || _findBy === void 0 ? void 0 : _findBy.name;
7734
+ }
7735
+ return nameAliases[selectedVal] || selectedVal;
7736
+ };
7737
+ var getDashBoardTitle = function getDashBoardTitle(_ref5) {
7738
+ var resourceName = _ref5.resourceName,
7739
+ isSingleResource = _ref5.isSingleResource,
7740
+ showStateFilter = _ref5.showStateFilter,
7741
+ selectedState = _ref5.selectedState,
7742
+ title = _ref5.title;
7182
7743
  var displayTitle = title;
7183
7744
  if (showStateFilter && !isSingleResource) {
7184
7745
  displayTitle = t$1("messages.stateTitleForResource", {
7185
7746
  state: selectedState,
7186
7747
  title: title,
7187
- resource: resource
7748
+ resource: resourceName
7188
7749
  });
7189
7750
  } else if (showStateFilter && isSingleResource) {
7190
7751
  displayTitle = "".concat(selectedState, " ").concat(title);
7191
7752
  } else if (!showStateFilter && !isSingleResource) {
7192
7753
  displayTitle = t$1("messages.titleForResource", {
7193
7754
  title: title,
7194
- resource: resource
7755
+ resource: resourceName
7195
7756
  });
7196
7757
  }
7197
7758
  return pure.humanize(displayTitle);
@@ -7214,6 +7775,24 @@ var renderNoDataHelpText = function renderNoDataHelpText(title, url) {
7214
7775
  }
7215
7776
  });
7216
7777
  };
7778
+ var getDeletionConfirmationMessage = function getDeletionConfirmationMessage(_ref6) {
7779
+ var resource = _ref6.resource,
7780
+ fieldName = _ref6.fieldName,
7781
+ affectedResourcesCount = _ref6.affectedResourcesCount;
7782
+ return affectedResourcesCount > 0 ? /*#__PURE__*/React__default["default"].createElement(Trans, {
7783
+ i18nKey: "messages.confirmDeleteWithCount",
7784
+ values: {
7785
+ resource: pluralize(resource, affectedResourcesCount),
7786
+ name: fieldName,
7787
+ count: affectedResourcesCount
7788
+ }
7789
+ }) : /*#__PURE__*/React__default["default"].createElement(Trans, {
7790
+ i18nKey: "messages.confirmDelete",
7791
+ values: {
7792
+ name: fieldName
7793
+ }
7794
+ });
7795
+ };
7217
7796
 
7218
7797
  var fetchConfigs = function fetchConfigs() {
7219
7798
  return axios__default["default"].get(CONFIGS_URL);
@@ -7388,18 +7967,23 @@ var useFieldsDashboard = function useFieldsDashboard(_ref) {
7388
7967
  };
7389
7968
  var isSingleResource = menuItems.length === 1;
7390
7969
  var isMenuBarNeeded = showStateFilter || !isSingleResource;
7391
- var headerDisplayTitle = React.useMemo(function () {
7392
- return getDashBoardTitle({
7970
+ var resourceName = React.useMemo(function () {
7971
+ return getResourceName({
7393
7972
  isOwnerBased: isOwnerBased,
7394
- owners: menuItems,
7395
- selectedVal: resource,
7396
7973
  nameAliases: nameAliases,
7974
+ owners: menuItems,
7975
+ selectedVal: resource
7976
+ });
7977
+ }, [menuItems, resource]);
7978
+ var headerDisplayTitle = React.useMemo(function () {
7979
+ return getDashBoardTitle({
7980
+ resourceName: resourceName,
7397
7981
  showStateFilter: showStateFilter,
7398
7982
  selectedState: state,
7399
7983
  isSingleResource: isSingleResource,
7400
7984
  title: title
7401
7985
  });
7402
- }, [resource, state, isSingleResource, menuItems]);
7986
+ }, [state, isSingleResource, resourceName]);
7403
7987
  var menuBarFilters = React.useMemo(function () {
7404
7988
  return renderMenuBarFilters({
7405
7989
  selectedState: state,
@@ -7437,6 +8021,7 @@ var useFieldsDashboard = function useFieldsDashboard(_ref) {
7437
8021
  selectedState: state,
7438
8022
  selectedMenu: resource,
7439
8023
  // resource will be ownerId if showOwnersInMenu is true, else it will be resourceType
8024
+ ownerId: ownerId,
7440
8025
  isFieldsFetching: isFieldsFetching,
7441
8026
  isFieldsLoading: isFieldsLoading,
7442
8027
  isDeleting: isDeleting,
@@ -7456,6 +8041,41 @@ var useFieldsDashboard = function useFieldsDashboard(_ref) {
7456
8041
  };
7457
8042
  };
7458
8043
 
8044
+ var DeleteAlert = function DeleteAlert(_ref) {
8045
+ var selectedField = _ref.selectedField,
8046
+ ownerId = _ref.ownerId,
8047
+ isDeleteAlertOpen = _ref.isDeleteAlertOpen,
8048
+ isDeleting = _ref.isDeleting,
8049
+ resourceTypeName = _ref.resourceTypeName,
8050
+ handleAlertClose = _ref.handleAlertClose,
8051
+ handleDelete = _ref.handleDelete;
8052
+ var _useTranslation = useTranslation(),
8053
+ t = _useTranslation.t;
8054
+ var _useFetchDependencies = useFetchDependencies({
8055
+ fieldId: selectedField.id,
8056
+ ownerId: ownerId
8057
+ }, {
8058
+ enabled: isDeleteAlertOpen && pure.isNotEmpty(selectedField)
8059
+ }),
8060
+ _useFetchDependencies2 = _useFetchDependencies.data,
8061
+ _useFetchDependencies3 = _useFetchDependencies2 === void 0 ? {} : _useFetchDependencies2,
8062
+ affectedResourcesCount = _useFetchDependencies3.affectedResourcesCount;
8063
+ return /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, {
8064
+ affectedResourcesCount: affectedResourcesCount,
8065
+ isOpen: isDeleteAlertOpen,
8066
+ isSubmitting: isDeleting,
8067
+ submitButtonLabel: t("labels.delete"),
8068
+ title: t("titles.deleteField"),
8069
+ message: getDeletionConfirmationMessage({
8070
+ resource: resourceTypeName,
8071
+ affectedResourcesCount: affectedResourcesCount,
8072
+ fieldName: selectedField === null || selectedField === void 0 ? void 0 : selectedField.name
8073
+ }),
8074
+ onClose: handleAlertClose,
8075
+ onSubmit: handleDelete
8076
+ });
8077
+ };
8078
+
7459
8079
  var FieldsTable = function FieldsTable(_ref) {
7460
8080
  var totalCount = _ref.totalCount,
7461
8081
  isLoading = _ref.isLoading,
@@ -11905,6 +12525,7 @@ var FieldsDashboard = function FieldsDashboard(_ref) {
11905
12525
  selectedField = _useFieldsDashboard.selectedField,
11906
12526
  selectedState = _useFieldsDashboard.selectedState,
11907
12527
  selectedMenu = _useFieldsDashboard.selectedMenu,
12528
+ ownerId = _useFieldsDashboard.ownerId,
11908
12529
  isFieldsFetching = _useFieldsDashboard.isFieldsFetching,
11909
12530
  isFieldsLoading = _useFieldsDashboard.isFieldsLoading,
11910
12531
  isDeleting = _useFieldsDashboard.isDeleting,
@@ -11989,13 +12610,14 @@ var FieldsDashboard = function FieldsDashboard(_ref) {
11989
12610
  ownerId: isOwnerBased ? selectedMenu : "",
11990
12611
  onClose: handleReorderPaneClose,
11991
12612
  allFields: allFields
11992
- }), /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, {
11993
- isOpen: isDeleteAlertOpen,
11994
- isSubmitting: isDeleting,
11995
- message: t("messages.confirmDelete"),
11996
- title: t("titles.deleteField"),
11997
- onClose: handleAlertClose,
11998
- onSubmit: handleDelete
12613
+ }), /*#__PURE__*/React__default["default"].createElement(DeleteAlert, {
12614
+ handleAlertClose: handleAlertClose,
12615
+ handleDelete: handleDelete,
12616
+ isDeleteAlertOpen: isDeleteAlertOpen,
12617
+ isDeleting: isDeleting,
12618
+ ownerId: ownerId,
12619
+ selectedField: selectedField,
12620
+ resourceTypeName: isOwnerBased ? resourceType : selectedMenu
11999
12621
  }));
12000
12622
  };
12001
12623