@visns-studio/visns-components 4.6.5 → 4.6.7

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.
@@ -653,6 +653,11 @@ function GenericDetail({
653
653
  case 'dynamicform':
654
654
  return (
655
655
  <GenericDynamic
656
+ buttons={
657
+ activeTabConfig.setting?.buttons
658
+ ? activeTabConfig.setting.buttons
659
+ : []
660
+ }
656
661
  data={data}
657
662
  fetchData={handleReload}
658
663
  label={
@@ -73,6 +73,7 @@ const renderValue = (field, data) => {
73
73
  };
74
74
 
75
75
  const GenericDynamic = ({
76
+ buttons,
76
77
  data,
77
78
  fetchData,
78
79
  label,
@@ -85,7 +86,6 @@ const GenericDynamic = ({
85
86
  type,
86
87
  userProfile,
87
88
  }) => {
88
- const toastId = useRef(null);
89
89
  const [activeForm, setActiveForm] = useState({});
90
90
  const [activeFormKey, setActiveFormKey] = useState(0);
91
91
 
@@ -372,6 +372,30 @@ const GenericDynamic = ({
372
372
  setActiveFormKey(key);
373
373
  };
374
374
 
375
+ const handleCustomButton = async (s) => {
376
+ let payload = {};
377
+ switch (s.type) {
378
+ case 'save':
379
+ if (s.payload?.length > 0) {
380
+ s.payload.forEach((p) => {
381
+ if (data[p]) {
382
+ payload[p] = data[p];
383
+ }
384
+ });
385
+ }
386
+
387
+ const res = await Download(s.url, s.method, payload);
388
+
389
+ if (res.data) {
390
+ saveAs(res.data);
391
+ }
392
+ break;
393
+ default:
394
+ console.info(s, 'default');
395
+ break;
396
+ }
397
+ };
398
+
375
399
  const handleAddNewForm = async (showToast = true) => {
376
400
  try {
377
401
  if (activeForm && activeForm.id) {
@@ -845,6 +869,21 @@ const GenericDynamic = ({
845
869
  )}
846
870
  </div>
847
871
  <div className={styles.polActions}>
872
+ {buttons.length > 0 &&
873
+ buttons.map((button, buttonKey) => (
874
+ <button
875
+ className={button.className}
876
+ key={`button-${buttonKey}`}
877
+ onClick={(e) => {
878
+ e.preventDefault();
879
+
880
+ handleCustomButton(button);
881
+ }}
882
+ >
883
+ {button.label}
884
+ </button>
885
+ ))}
886
+
848
887
  {multiple && templateStatus && (
849
888
  <button className="btn" onClick={handleAddNewForm}>
850
889
  Add New Form
@@ -168,7 +168,7 @@
168
168
 
169
169
  .app-nav .nav-item > ul li a {
170
170
  background: rgba(var(--primary-color-rgb), 0.9);
171
- color: var(--tertiary-color);
171
+ color: var(--tertiary-color) !important;
172
172
  }
173
173
 
174
174
  .app-nav .nav-item-alternate > ul li a {
package/package.json CHANGED
@@ -58,7 +58,7 @@
58
58
  "react-dom": "^17.0.1"
59
59
  },
60
60
  "name": "@visns-studio/visns-components",
61
- "version": "4.6.5",
61
+ "version": "4.6.7",
62
62
  "description": "Various packages to assist in the development of our Custom Applications.",
63
63
  "main": "index.js",
64
64
  "scripts": {