datastake-daf 0.6.799 → 0.6.801

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.
@@ -50942,7 +50942,7 @@ class AdminService extends BaseService {
50942
50942
  const type = subject === 'location' ? 'location' : 'stakeholder';
50943
50943
  return this.apiPut({
50944
50944
  url: `/management/subject/${type}/${id}`,
50945
- data
50945
+ data: filterCreateData(data)
50946
50946
  });
50947
50947
  }
50948
50948
  deleteSubject({
@@ -57749,20 +57749,19 @@ const usePrepareForm$1 = ({
57749
57749
  } = JSON.parse(JSON.stringify(allData[dKey][nKey] || {}));
57750
57750
  console.log("here", dKey, nKey);
57751
57751
  if (data.datastakeId === id || id === "user" || data.id === id) {
57752
- console.log("here2", data.datastakeId, id, data.id);
57753
- // if (viewConfig.linkingSubjects.includes(namespace)) {
57754
- setForm({
57755
- ...form,
57756
- linking: {
57757
- position: 100,
57758
- excludeFromEdit: true,
57759
- label: t("Linked Subjects"),
57760
- template: "linkingSubjects"
57761
- }
57762
- });
57763
- // } else {
57764
- // setForm(form);
57765
- // }
57752
+ if (viewConfig.adminNamespaces.includes(namespace)) {
57753
+ setForm(form);
57754
+ } else {
57755
+ setForm({
57756
+ ...form,
57757
+ linking: {
57758
+ position: 100,
57759
+ excludeFromEdit: true,
57760
+ label: t("Linked Subjects"),
57761
+ template: "linkingSubjects"
57762
+ }
57763
+ });
57764
+ }
57766
57765
  setData(data);
57767
57766
  setGroups(config.groups || {});
57768
57767
  setLinkingForms(linkingForms);
@@ -58533,10 +58532,7 @@ const View = ({
58533
58532
  namespaceOverrides: namespaceOverrides
58534
58533
  });
58535
58534
  const groupForm = React.useMemo(() => {
58536
- // If no group is specified, use the first available group
58537
- const formKeys = Object.keys(form || {});
58538
- const selectedGroup = group || (formKeys.length > 0 ? formKeys[0] : null);
58539
- const gF = selectedGroup ? form[selectedGroup] || {} : {};
58535
+ const gF = form[group] || {};
58540
58536
  if (subsection) {
58541
58537
  const sectionForms = groupSubsections(gF);
58542
58538
  if (sectionForms[subsection]) {
@@ -58660,7 +58656,7 @@ const View = ({
58660
58656
  actionButtons: actionButtons,
58661
58657
  extraButtons: extraPageActions,
58662
58658
  addedHeaderFirst: true,
58663
- addedHeader: /*#__PURE__*/jsxRuntime.jsx("div", {
58659
+ addedHeader: namespaceConfig?.isAdmin ? null : /*#__PURE__*/jsxRuntime.jsx("div", {
58664
58660
  className: "flex flex-row gap-4",
58665
58661
  children: /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
58666
58662
  options: [...sourceOptions],
@@ -58780,7 +58776,7 @@ const usePrepareForm = ({
58780
58776
  d[k] = undefined;
58781
58777
  }
58782
58778
  });
58783
- if (d.datastakeId === id || d.applicationId === id || id === "user") {
58779
+ if (d.datastakeId === id || d.applicationId === id || id === "user" || d.id === id) {
58784
58780
  const formG = mapFormGroup(allData[dKey][nKey].form || {}, d);
58785
58781
  setForm(formG);
58786
58782
  if (setExtra) {
@@ -683,6 +683,80 @@ class BaseService extends BaseHTTPService {
683
683
  }
684
684
  }
685
685
 
686
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
687
+
688
+ function createCommonjsModule(fn, module) {
689
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
690
+ }
691
+
692
+ var customParseFormat = createCommonjsModule(function (module, exports) {
693
+ !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
694
+ });
695
+
696
+ var utc = createCommonjsModule(function (module, exports) {
697
+ !function(t,i){module.exports=i();}(commonjsGlobal,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t);};var r=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds();}else r.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r;}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
698
+ });
699
+
700
+ var localizedFormat = createCommonjsModule(function (module, exports) {
701
+ !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(t,o,n){var r=o.prototype,i=r.format;n.en.formats=e,r.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var o=this.$locale().formats,n=function(t,o){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||o[r]||e[r]||o[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,o){return t||o.slice(1)}))}))}(t,void 0===o?{}:o);return i.call(this,n)};}}));
702
+ });
703
+
704
+ createCommonjsModule(function (module, exports) {
705
+ !function(e,n){module.exports=n(dayjs__default["default"]);}(commonjsGlobal,(function(e){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(e),i={name:"fr",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return ""+e+(1===e?"er":"")}};return t.default.locale(i,null,!0),i}));
706
+ });
707
+
708
+ createCommonjsModule(function (module, exports) {
709
+ !function(e,o){module.exports=o(dayjs__default["default"]);}(commonjsGlobal,(function(e){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(e),d={name:"es",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return s.default.locale(d,null,!0),d}));
710
+ });
711
+
712
+ createCommonjsModule(function (module, exports) {
713
+ !function(e,n){module.exports=n();}(commonjsGlobal,(function(){return {name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var n=["th","st","nd","rd"],t=e%100;return "["+e+(n[(t-20)%10]||n[t]||n[0])+"]"}}}));
714
+ });
715
+
716
+ /* eslint-disable no-case-declarations */
717
+ dayjs__default["default"].extend(customParseFormat);
718
+ dayjs__default["default"].extend(utc);
719
+ dayjs__default["default"].extend(utc);
720
+ dayjs__default["default"].extend(localizedFormat);
721
+ const isObjectEmpty = obj => {
722
+ if (obj === null || typeof obj !== "object") {
723
+ return false;
724
+ }
725
+ if (Object.keys(obj).length === 0) {
726
+ return true;
727
+ }
728
+ return Object.values(obj).every(value => isObjectEmpty(value));
729
+ };
730
+
731
+ /**
732
+ * Filters and processes the input data by extracting specific properties.
733
+ * It checks if the 'meta' property is empty and sets it to undefined if so,
734
+ * then returns the rest of the data merged with the processed 'meta'. Used to clear data
735
+ * when they are sent to backend.
736
+ *
737
+ * @param {Object} data - The input data object containing various properties.
738
+ * @returns {Object} - The processed data object with filtered properties.
739
+ */
740
+
741
+ const filterCreateData = data => {
742
+ // eslint-disable-next-line no-unused-vars
743
+ const {
744
+ view,
745
+ module,
746
+ scope,
747
+ form,
748
+ meta,
749
+ createdAt,
750
+ updatedAt,
751
+ ...rest
752
+ } = data;
753
+ const _meta = isObjectEmpty(meta) ? undefined : meta;
754
+ return {
755
+ ...rest,
756
+ meta: _meta
757
+ };
758
+ };
759
+
686
760
  class AdminService extends BaseService {
687
761
  updateCompany(id, data) {
688
762
  return this.apiPut({
@@ -860,7 +934,7 @@ class AdminService extends BaseService {
860
934
  const type = subject === 'location' ? 'location' : 'stakeholder';
861
935
  return this.apiPut({
862
936
  url: `/management/subject/${type}/${id}`,
863
- data
937
+ data: filterCreateData(data)
864
938
  });
865
939
  }
866
940
  deleteSubject({
@@ -1349,80 +1423,6 @@ class DashboardService extends BaseService {
1349
1423
  }
1350
1424
  var DashboardService$1 = createLazyService(DashboardService);
1351
1425
 
1352
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1353
-
1354
- function createCommonjsModule(fn, module) {
1355
- return module = { exports: {} }, fn(module, module.exports), module.exports;
1356
- }
1357
-
1358
- var customParseFormat = createCommonjsModule(function (module, exports) {
1359
- !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
1360
- });
1361
-
1362
- var utc = createCommonjsModule(function (module, exports) {
1363
- !function(t,i){module.exports=i();}(commonjsGlobal,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t);};var r=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds();}else r.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r;}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
1364
- });
1365
-
1366
- var localizedFormat = createCommonjsModule(function (module, exports) {
1367
- !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(t,o,n){var r=o.prototype,i=r.format;n.en.formats=e,r.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var o=this.$locale().formats,n=function(t,o){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||o[r]||e[r]||o[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,o){return t||o.slice(1)}))}))}(t,void 0===o?{}:o);return i.call(this,n)};}}));
1368
- });
1369
-
1370
- createCommonjsModule(function (module, exports) {
1371
- !function(e,n){module.exports=n(dayjs__default["default"]);}(commonjsGlobal,(function(e){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(e),i={name:"fr",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return ""+e+(1===e?"er":"")}};return t.default.locale(i,null,!0),i}));
1372
- });
1373
-
1374
- createCommonjsModule(function (module, exports) {
1375
- !function(e,o){module.exports=o(dayjs__default["default"]);}(commonjsGlobal,(function(e){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(e),d={name:"es",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return s.default.locale(d,null,!0),d}));
1376
- });
1377
-
1378
- createCommonjsModule(function (module, exports) {
1379
- !function(e,n){module.exports=n();}(commonjsGlobal,(function(){return {name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var n=["th","st","nd","rd"],t=e%100;return "["+e+(n[(t-20)%10]||n[t]||n[0])+"]"}}}));
1380
- });
1381
-
1382
- /* eslint-disable no-case-declarations */
1383
- dayjs__default["default"].extend(customParseFormat);
1384
- dayjs__default["default"].extend(utc);
1385
- dayjs__default["default"].extend(utc);
1386
- dayjs__default["default"].extend(localizedFormat);
1387
- const isObjectEmpty = obj => {
1388
- if (obj === null || typeof obj !== "object") {
1389
- return false;
1390
- }
1391
- if (Object.keys(obj).length === 0) {
1392
- return true;
1393
- }
1394
- return Object.values(obj).every(value => isObjectEmpty(value));
1395
- };
1396
-
1397
- /**
1398
- * Filters and processes the input data by extracting specific properties.
1399
- * It checks if the 'meta' property is empty and sets it to undefined if so,
1400
- * then returns the rest of the data merged with the processed 'meta'. Used to clear data
1401
- * when they are sent to backend.
1402
- *
1403
- * @param {Object} data - The input data object containing various properties.
1404
- * @returns {Object} - The processed data object with filtered properties.
1405
- */
1406
-
1407
- const filterCreateData = data => {
1408
- // eslint-disable-next-line no-unused-vars
1409
- const {
1410
- view,
1411
- module,
1412
- scope,
1413
- form,
1414
- meta,
1415
- createdAt,
1416
- updatedAt,
1417
- ...rest
1418
- } = data;
1419
- const _meta = isObjectEmpty(meta) ? undefined : meta;
1420
- return {
1421
- ...rest,
1422
- meta: _meta
1423
- };
1424
- };
1425
-
1426
1426
  dayjs__default["default"].extend(utc);
1427
1427
  const removeKeysFromObject = (obj = {}, keys = []) => {
1428
1428
  if (typeof obj !== 'object' || obj === null) return obj;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.799",
3
+ "version": "0.6.801",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -41,7 +41,8 @@ export default function AdminLocationScreen({ config }) {
41
41
  headerTitle = "location",
42
42
  breadcrumbs,
43
43
  refetchTrigger,
44
- getData
44
+ getData,
45
+ user,
45
46
  } = config;
46
47
 
47
48
  const handleMergeLocations = useCallback(
@@ -89,6 +90,8 @@ export default function AdminLocationScreen({ config }) {
89
90
  countries: options?.countries,
90
91
  },
91
92
  }}
93
+ user={user}
94
+ options={options}
92
95
  />
93
96
  );
94
97
  }
@@ -42,6 +42,7 @@ export default function AdminSubjectsScreen({ config }) {
42
42
  breadcrumbs,
43
43
  refetchTrigger,
44
44
  getData,
45
+ user,
45
46
  } = config;
46
47
 
47
48
  const handleMergeSubjects = useCallback(
@@ -89,6 +90,8 @@ export default function AdminSubjectsScreen({ config }) {
89
90
  countries: options?.countries,
90
91
  },
91
92
  }}
93
+ user={user}
94
+ options={options}
92
95
  />
93
96
  );
94
97
  }
@@ -13,6 +13,8 @@ export const getColumns = ({
13
13
  setSelectedLocations,
14
14
  selectOptions,
15
15
  entity,
16
+ user,
17
+ options,
16
18
  }) => {
17
19
  const cols = [
18
20
  {
@@ -105,7 +107,7 @@ export const getColumns = ({
105
107
  },
106
108
  },
107
109
  {
108
- title: t("Admin Level 1"),
110
+ title: findOptions(user?.company?.country, options?.administrativeLevel1)?.length > 2 ? findOptions(user?.company?.country, options?.administrativeLevel1) : t("Province"),
109
111
  dataIndex: "administrativeLevel1",
110
112
  key: "administrativeLevel1",
111
113
  ellipsis: true,
@@ -126,7 +128,7 @@ export const getColumns = ({
126
128
  },
127
129
  },
128
130
  {
129
- title: t("Admin Level 2"),
131
+ title: findOptions(user?.company?.country, options?.administrativeLevel2)?.length > 2 ? findOptions(user?.company?.country, options?.administrativeLevel2) : t("Territory"),
130
132
  dataIndex: "administrativeLevel2",
131
133
  key: "administrativeLevel2",
132
134
  show: entity.includes("location"),
@@ -31,6 +31,8 @@ export default function LocationTable({
31
31
  breadcrumbs,
32
32
  mergeLocationsFunction,
33
33
  refetchTrigger,
34
+ user,
35
+ options,
34
36
  }) {
35
37
  const [showFilters, setShowFilters] = useState(false);
36
38
  const [hasError, setHasError] = useState(false);
@@ -116,7 +118,9 @@ export default function LocationTable({
116
118
  setSelectedLocations,
117
119
  getRedirectLink,
118
120
  selectOptions,
119
- entity: headerTitle
121
+ entity: headerTitle,
122
+ user,
123
+ options,
120
124
  });
121
125
  }, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions, headerTitle]);
122
126
 
@@ -13,6 +13,7 @@ export const getColumns = ({
13
13
  setSelectedSubjects,
14
14
  selectOptions,
15
15
  entity,
16
+ options,
16
17
  }) => {
17
18
  const cols = [
18
19
  {
@@ -84,7 +85,8 @@ export const getColumns = ({
84
85
  return <div className="daf-default-cell" />;
85
86
  }
86
87
 
87
- const category = findOptions(value, selectOptions?.category || []) || "--";
88
+ console.log({value, options})
89
+ const category = findOptions(value, options?.categoriesOptions || []) || "-";
88
90
 
89
91
  return <Tooltip title={category}>{category}</Tooltip>;
90
92
  },
@@ -99,7 +101,7 @@ export const getColumns = ({
99
101
  if (all.empty) {
100
102
  return <div className="daf-default-cell" />;
101
103
  }
102
- const country = findOptions(value, selectOptions?.country || []) || "--";
104
+ const country = findOptions(value, options?.countries || []) || "-";
103
105
 
104
106
  return <Tooltip title={country}>{country}</Tooltip>;
105
107
  },
@@ -31,6 +31,8 @@ export default function SubjectsTable({
31
31
  breadcrumbs,
32
32
  mergeSubjectsFunction,
33
33
  refetchTrigger,
34
+ user,
35
+ options,
34
36
  }) {
35
37
  const [showFilters, setShowFilters] = useState(false);
36
38
  const [hasError, setHasError] = useState(false);
@@ -116,9 +118,10 @@ const getDataWithStringPagination = async ({ params }) => {
116
118
  setSelectedSubjects,
117
119
  getRedirectLink,
118
120
  selectOptions,
119
- entity: headerTitle
121
+ entity: headerTitle,
122
+ options,
120
123
  });
121
- }, [t, goTo, module, token, selectedSubjects, getRedirectLink, selectOptions, headerTitle]);
124
+ }, [t, goTo, module, token, selectedSubjects, getRedirectLink, selectOptions, headerTitle, options]);
122
125
 
123
126
  return (
124
127
  <>
@@ -158,50 +158,6 @@ export function getAdminRoutes(config) {
158
158
  },
159
159
  ]
160
160
  : []),
161
- ...(typeof useAdminLocationViewConfig === "function"
162
- ? [
163
- // {
164
- // path: "view/management-location/:id",
165
- // key: `${APP_PREFIX}_ADMIN_LOCATION_VIEW`,
166
- // exact: true,
167
- // visible: (user) => userIsAdmin(user),
168
- // component: <LocationViewWrapper />,
169
- // },
170
- ]
171
- : []),
172
- ...(typeof useAdminSubjectsViewConfig === "function"
173
- ? [
174
- {
175
- path: "view/management-stakeholder/:id",
176
- key: `${APP_PREFIX}_ADMIN_STAKEHOLDER_VIEW`,
177
- exact: true,
178
- visible: (user) => userIsAdmin(user),
179
- component: <StakeholderViewWrapper />,
180
- },
181
- ]
182
- : []),
183
- ...(typeof useAdminLocationViewConfig === "function"
184
- ? [
185
- {
186
- path: "edit/management-location/:id",
187
- key: `${APP_PREFIX}_ADMIN_LOCATION_EDIT`,
188
- exact: true,
189
- visible: (user) => userIsAdmin(user),
190
- component: <LocationEditWrapper />,
191
- },
192
- ]
193
- : []),
194
- ...(typeof useAdminSubjectsViewConfig === "function"
195
- ? [
196
- {
197
- path: "edit/management-stakeholder/:id",
198
- key: `${APP_PREFIX}_ADMIN_STAKEHOLDER_EDIT`,
199
- exact: true,
200
- visible: (user) => userIsAdmin(user),
201
- component: <StakeholderEditWrapper />,
202
- },
203
- ]
204
- : []),
205
161
  ];
206
162
 
207
163
  return routes;
@@ -36,7 +36,7 @@ export const usePrepareForm = ({
36
36
  d[k] = undefined;
37
37
  }
38
38
  });
39
- if (d.datastakeId === id || d.applicationId === id || id === "user") {
39
+ if (d.datastakeId === id || d.applicationId === id || id === "user" || d.id === id) {
40
40
  const formG = mapFormGroup(allData[dKey][nKey].form || {}, d);
41
41
  setForm(formG);
42
42
 
@@ -38,10 +38,11 @@ export const usePrepareForm = ({
38
38
  console.log("here", dKey, nKey)
39
39
 
40
40
  if (data.datastakeId === id || id === "user" || data.id === id) {
41
- console.log("here2", data.datastakeId, id, data.id)
42
- // if (viewConfig.linkingSubjects.includes(namespace)) {
41
+ if (viewConfig.adminNamespaces.includes(namespace)) {
42
+ setForm(form);
43
+ } else {
43
44
  setForm({
44
- ...form,
45
+ ...form,
45
46
  linking: {
46
47
  position: 100,
47
48
  excludeFromEdit: true,
@@ -49,9 +50,7 @@ export const usePrepareForm = ({
49
50
  template: "linkingSubjects",
50
51
  },
51
52
  });
52
- // } else {
53
- // setForm(form);
54
- // }
53
+ }
55
54
  setData(data);
56
55
  setGroups(config.groups || {});
57
56
  setLinkingForms(linkingForms);
@@ -116,11 +116,7 @@ const View = ({
116
116
  });
117
117
 
118
118
  const groupForm = useMemo(() => {
119
- // If no group is specified, use the first available group
120
- const formKeys = Object.keys(form || {});
121
- const selectedGroup = group || (formKeys.length > 0 ? formKeys[0] : null);
122
- const gF = selectedGroup ? (form[selectedGroup] || {}) : {};
123
-
119
+ const gF = form[group] || {};
124
120
  if (subsection) {
125
121
  const sectionForms = groupSubsections(gF);
126
122
  if (sectionForms[subsection]) {
@@ -241,7 +237,7 @@ const View = ({
241
237
  extraButtons={extraPageActions}
242
238
  addedHeaderFirst
243
239
  addedHeader={
244
- <div className="flex flex-row gap-4">
240
+ namespaceConfig?.isAdmin ? null : <div className="flex flex-row gap-4">
245
241
  <Multiselect
246
242
  options={[...sourceOptions]}
247
243
  isAvatarGroup
@@ -1,5 +1,6 @@
1
1
  import { BaseService } from './BaseService.js';
2
2
  import { createLazyService } from './helpers/LazyService.js';
3
+ import { filterCreateData } from "../../helpers/Forms.js";
3
4
 
4
5
  class AdminService extends BaseService {
5
6
  updateCompany(id, data) {
@@ -165,7 +166,7 @@ class AdminService extends BaseService {
165
166
  const type = subject === 'location' ? 'location' : 'stakeholder';
166
167
  return this.apiPut({
167
168
  url: `/management/subject/${type}/${id}`,
168
- data,
169
+ data: filterCreateData(data),
169
170
  });
170
171
  }
171
172