You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
19 KiB
2 lines
19 KiB
/*! For license information please see 7.273fddee.chunk.js.LICENSE.txt */ |
|
(this["webpackJsonpsimpro-web"]=this["webpackJsonpsimpro-web"]||[]).push([[7],{1682:function(e,t,n){"use strict";var r=n(745),a=n(737),o=n(607),c=n(733),l=n(184),i=n(185),s=n(188),u=n(186),d=n(187),f=n(2),p=n.n(f),h=n(1169),m=n.n(h),g=n(1170),v=n.n(g),y=n(1171),b=n.n(y),w=n(1172),E=n.n(w),S=n(817),O=n(814),A=n(815),j=n(827),x=n(828),T=n(783),k=n(816),C=n(757),R=n(792),N=n(793),M=n(806),L=n(819),P=n(807),F=n(812),_=(n(971),n(1173)),D=n.n(_),I=n(1082),G=n.n(I),J=n(938),Y=n(1934),B=(n(2128),n(665)),V=n.n(B),W=n(597),z=n.n(W);function H(){H=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",c=r.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(x){l=function(e,t,n){return e[t]=n}}function i(e,t,n,r){var a=t&&t.prototype instanceof d?t:d,o=Object.create(a.prototype),c=new O(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return j()}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var l=w(c,n);if(l){if(l===u)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var i=s(e,t,n);if("normal"===i.type){if(r=n.done?"completed":"suspendedYield",i.arg===u)continue;return{value:i.arg,done:n.done}}"throw"===i.type&&(r="completed",n.method="throw",n.arg=i.arg)}}}(e,n,c),o}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(x){return{type:"throw",arg:x}}}e.wrap=i;var u={};function d(){}function f(){}function p(){}var h={};l(h,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(A([])));g&&g!==t&&n.call(g,a)&&(h=g);var v=p.prototype=d.prototype=Object.create(h);function y(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var r;this._invoke=function(a,o){function c(){return new t((function(r,c){!function r(a,o,c,l){var i=s(e[a],e,o);if("throw"!==i.type){var u=i.arg,d=u.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,c,l)}),(function(e){r("throw",e,c,l)})):t.resolve(d).then((function(e){u.value=e,c(u)}),(function(e){return r("throw",e,c,l)}))}l(i.arg)}(a,o,r,c)}))}return r=r?r.then(c,c):c()}}function w(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var r=s(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,u;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function A(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:j}}function j(){return{value:void 0,done:!0}}return f.prototype=p,l(v,"constructor",p),l(p,"constructor",f),f.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},y(b.prototype),l(b.prototype,o,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var c=new b(i(t,n,r,a),o);return e.isGeneratorFunction(n)?c:c.next().then((function(e){return e.done?e.value:c.next()}))},y(v),l(v,c,"Generator"),l(v,a,(function(){return this})),l(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=A,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return c.type="throw",c.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var l=n.call(o,"catchLoc"),i=n.call(o,"finallyLoc");if(l&&i){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!i)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var c=o?o.completion:{};return c.type=e,c.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(c)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),u}},e}var U=[{dataField:"id",text:"Id"}],Z=g.Search.SearchBar,$=g.CSVExport.ExportCSVButton,q=function(e){Object(u.a)(n,e);var t=Object(d.a)(n);function n(e){var i;Object(l.a)(this,n);var u=e.columns.reduce((function(e,t){return e[t.dataField]=t.state,e}),{});return(i=t.call(this,e)).getDataTable=function(){fetch(i.props.urlParamGet,{method:"POST",header:JSON.stringify({"Content-Type":"application/json"})}).then((function(e){return e.json()})).then((function(e){if("Success"===e.code_message){for(var t=[],n=0;n<e.data.length;n++)t.push(e.data[n]);i.mapTableInit(t)}else console.log("gagal login")})).catch((function(e){}))},i.toggleEditCell=function(){var e=i.state.editCellMode;console.log("editCellMode ",e),e?i.setState({editCellMode:!1,selectRow:{mode:"checkbox",clickToSelect:!0,clickToEdit:!1,bgColor:"#e4e5e6",onSelect:function(e,t,n,r){return i.onSelectRowTable({row:e,isSelect:t,e:r,rowIndex:n})},onSelectAll:function(e,t,n){return i.onSelectAllRowTable(e,t,n)}},selectedRows:[]}):i.setState({editCellMode:!0,selectRow:{mode:"checkbox",clickToSelect:!1,clickToEdit:!0,bgColor:"#e4e5e6",onSelect:function(e,t,n,r){return i.onSelectRowTable({row:e,isSelect:t,e:r,rowIndex:n})},onSelectAll:function(e,t,n){return i.onSelectAllRowTable(e,t,n)}}})},i.onSelectRowTable=function(e){var t=e.row,n=e.isSelect,r=(e.e,i.state.selectedRows);if("object"===typeof t)if(n)i.setState({selectedRows:[].concat(Object(c.a)(r),[t])});else{var a=r.indexOf(t);r.splice(a,1),i.setState({selectedRows:r})}else console.log("type array"),i.setState({selectedRows:t})},i.onSelectAllRowTable=function(e,t,n){console.log("onSelectAllRowTable isSelect, rows, e",e,t,n);i.state.selectedRows;if(!1===e)i.setState({selectedRows:[]},(function(){console.log("onSelectAllRowTable selectedRows",i.state.selectedRows)}));else if(!0===e){var r=t.map((function(e,t){return e}));console.log("row",r),i.setState({selectedRows:r},(function(){console.log("onSelectAllRowTable selectedRows",i.state.selectedRows)}))}},i.openModalAdd=function(){return i.setState({modalAdd:!0})},i.closeModalAdd=function(){return i.setState({modalAdd:!1})},i.saveModalAdd=Object(o.a)(H().mark((function e(){var t,n,o,c,l;return H().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.props.columns,n=t.reduce((function(e,t){return e[t.dataField]=t.state,e}),{}),o=t.reduce((function(e,t){return Object.assign(e,Object(a.a)({},t.dataField,"last_updated"===t.dataField||"created_time"===t.dataField||"modified_time"===t.dataField?z()().format("YYYY-MM-DD HH:mm:ssZ"):i.state[t.dataField]))}),{}),console.log("payload insert",o),c={method:"POST",header:JSON.stringify({"Content-Type":"application/json"}),body:JSON.stringify(o)},e.prev=5,e.next=8,fetch(i.props.urlParamInsert,c).then((function(e){return e.json()})).then((function(e){return e}));case 8:(l=e.sent).data?(i.getDataTable(),i.setState(Object(r.a)({modalAdd:!1,alert:!0,messageAlert:l.code_message,successAlert:!0,dangerAlert:!1},n))):i.setState(Object(r.a)({modalAdd:!1,alert:!0,messageAlert:l.code_message,successAlert:!1,dangerAlert:!0},n)),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(5),i.setState({modalAdd:!1,alert:!0,messageAlert:"Opss! looks like something wrong",successAlert:!1,dangerAlert:!0});case 15:case"end":return e.stop()}}),e,null,[[5,12]])}))),i.modalAdd=function(){var e=i.props.columns;return p.a.createElement("div",null,p.a.createElement(S.a,{isOpen:i.state.modalAdd,toggle:i.closeModalAdd},p.a.createElement(O.a,{toggle:i.closeModalAdd},"Add new ",i.props.title),p.a.createElement(A.a,null,e.map((function(e,t){if(e.showInput)return p.a.createElement(j.a,{key:t},p.a.createElement(x.a,{for:"exampleEmail"},e.alias),p.a.createElement(T.a,{onChange:function(t){return i.setState(Object(a.a)({},e.dataField,t.target.value))},type:e.type}))}))),p.a.createElement(k.a,null,p.a.createElement(C.a,{color:"secondary",onClick:i.closeModalAdd},"Cancel"),p.a.createElement(C.a,{color:"primary",onClick:i.saveModalAdd},"Save")," ")))},i.updateFunction=function(){var e=Object(o.a)(H().mark((function e(t,n,r,a){var o,c,l;return H().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=i.state.editCellMode,console.log("editCellMode",o),console.log(r),c={method:"POST",header:JSON.stringify({"Content-Type":"application/json"}),body:JSON.stringify(r)},e.next=6,fetch(i.props.urlParamUpdate,c).then((function(e){return e.json()})).then((function(e){return e}));case 6:(l=e.sent).data?(i.getDataTable(),i.setState({alert:!0,successAlert:!0,dangerAlert:!1,messageAlert:l.code_message,editCellMode:!1,selectedRows:[]})):i.setState({alert:!0,successAlert:!1,dangerAlert:!0,messageAlert:l.code_message,editCellMode:!1,selectedRows:[]});case 8:case"end":return e.stop()}}),e)})));return function(t,n,r,a){return e.apply(this,arguments)}}(),i.handleDelete=function(e){},i.deleteFunction=function(){var e=Object(o.a)(H().mark((function e(t){var n,a,o,c,l;return H().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=i.state.selectedRows,console.log("row selected",n),"delete"!==t){e.next=18;break}return a=i.props.columns,o=a.reduce((function(e,t){return e[t.dataField]=t.state,e}),{}),c={method:"POST",header:JSON.stringify({"Content-Type":"application/json"}),body:JSON.stringify(n)},e.prev=6,e.next=9,fetch(i.props.urlParamDelete,c).then((function(e){return e.json()})).then((function(e){return e}));case 9:(l=e.sent).data?(i.getDataTable(),i.setState(Object(r.a)(Object(r.a)({alert:!0,alertWarning:!1,messageAlert:l.code_message,successAlert:!0,dangerAlert:!1},o),{},{selectedRows:[]}))):i.setState(Object(r.a)(Object(r.a)({alert:!0,alertWarning:!1,messageAlert:l.code_message,successAlert:!1,dangerAlert:!0},o),{},{selectedRows:[]})),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(6),i.setState({alert:!0,messageAlert:"Opss! looks like something wrong",successAlert:!1,dangerAlert:!0,selectedRows:[]});case 16:e.next=19;break;case 18:i.setState({alertWarning:!1});case 19:case"end":return e.stop()}}),e,null,[[6,13]])})));return function(t){return e.apply(this,arguments)}}(),i.allDeleteFunction=function(){console.log()},i.state=Object(r.a)({columns:[],data:[],selectRow:{mode:"checkbox",clickToSelect:!0,clickToEdit:!1,bgColor:"#e4e5e6",onSelect:function(e,t,n,r){return i.onSelectRowTable({row:e,isSelect:t,e:r,rowIndex:n})},onSelectAll:function(e,t,n){return i.onSelectAllRowTable(e,t,n)}},editCellMode:!1,onSelectAllMode:!1,selectedRows:[],alert:!1,alertWarning:!1,successAlert:!1,dangerAlert:!1,messageAlert:"",modalAdd:!1},u),i.mapTableInit=i.mapTableInit.bind(Object(s.a)(i)),i.addNewData=i.addNewData.bind(Object(s.a)(i)),i}return Object(i.a)(n,[{key:"componentDidMount",value:function(){this.getDataTable()}},{key:"mapTableInit",value:function(e){var t=[];if(e.length>0)for(var n in e[0])t.push({dataField:n,text:n,sort:!0});this.setState({columns:0!==e.length?t:U,data:e})}},{key:"addNewData",value:function(){alert("add new data")}},{key:"render",value:function(){var e=this,t=this.state,n=t.columns,r=t.data,a=t.selectedRows,o=t.selectRow,c=t.editCellMode,l=t.alert,i=t.messageAlert,s=t.alertWarning,u=(t.deleteData,t.successAlert),d=t.dangerAlert;return p.a.createElement("div",{className:"animated fadeIn"},p.a.createElement(V.a,{show:l,success:u,danger:d,title:i,onConfirm:function(){return e.setState({alert:!1,successAlert:!1,dangerAlert:!1})}},i),p.a.createElement(V.a,{show:s,warning:!0,showCancel:!0,confirmBtnText:"Yes, delete it!",confirmBtnBsStyle:"danger",title:"Are you sure?",onConfirm:function(){return e.deleteFunction("delete")},onCancel:function(){return e.deleteFunction("cancel")},focusCancelBtn:!0},"This ",this.props.title," will be deleted"),p.a.createElement(R.a,null,p.a.createElement(N.a,{xl:12},p.a.createElement(M.a,null,p.a.createElement(L.a,null,p.a.createElement(R.a,null,p.a.createElement(N.a,{xl:6,xs:6},p.a.createElement("i",{className:"fa fa-align-justify"}),"Master ",void 0!==this.props.title?this.props.title:"DataTable"),p.a.createElement(N.a,{xl:6,xs:6},p.a.createElement("div",{className:"add-button-container"},p.a.createElement(C.a,{color:"primary",size:"sm",outline:!0,onClick:this.openModalAdd},p.a.createElement(F.Icon,{icon:G.a,width:15,height:15})," Add New Data"),this.modalAdd())))),p.a.createElement(P.a,null,0===r.length?p.a.createElement("div",null,"No result found"):p.a.createElement("div",null,p.a.createElement(v.a,{keyField:"id",data:r,columns:n,search:!0,exportCSV:!0},(function(t){return p.a.createElement("div",null,p.a.createElement(R.a,null,p.a.createElement(N.a,{xl:6,xs:6},p.a.createElement("div",{className:"search-bar-wrapper"},p.a.createElement(Z,t.searchProps))),p.a.createElement(N.a,{xl:6,xs:6},p.a.createElement("div",{className:"table-option-button-group pull-right"},p.a.createElement(R.a,null,p.a.createElement("div",{style:{paddingRight:5},className:"switch-button-upper clearfix"},p.a.createElement("small",null,p.a.createElement("b",null,"Edit")),p.a.createElement("br",null),p.a.createElement(J.l,{className:"float-right",variant:"pill",label:!0,color:"success",size:"sm",onChange:function(){return e.toggleEditCell()},checked:c})),p.a.createElement("div",{className:"clearfix"},a.length>0&&!c&&p.a.createElement(C.a,{onClick:function(){return e.setState({alertWarning:!0})},size:"sm",outline:!0,color:"danger"},p.a.createElement("i",{className:"cil-trash"})),p.a.createElement($,t.csvProps,p.a.createElement(C.a,{color:"success",size:"sm",outline:!0,id:"exportCSVTooltip"},p.a.createElement(F.Icon,{icon:D.a,width:20,height:20}))),p.a.createElement(Y.a,{placement:"top",target:"exportCSVTooltip"},"Export CSV")))))),p.a.createElement("div",{className:"table-wrapper"},c?p.a.createElement(m.a,Object.assign({},t.baseProps,{bootstrap4:!0,keyField:"id",hover:!0,pagination:b()(),noDataIndication:"No results found",selectRow:o,cellEdit:E()({mode:"click",blurToSave:!0,timeToCloseMessage:2500,errorMessage:"",afterSaveCell:function(t,n,r,a){return e.updateFunction(t,n,r,a)}})})):p.a.createElement(m.a,Object.assign({},t.baseProps,{bootstrap4:!0,keyField:"id",hover:!0,pagination:b()(),noDataIndication:"No results found",selectRow:o}))))}))))))))}}]),n}(f.Component);t.a=q},2128:function(e,t,n){},650:function(e,t,n){"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return r}))},655:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(650);function a(e,t){if(e){if("string"===typeof e)return Object(r.a)(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Object(r.a)(e,t):void 0}}},733:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(650);var a=n(655);function o(e){return function(e){if(Array.isArray(e))return Object(r.a)(e)}(e)||function(e){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||Object(a.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},737:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",(function(){return r}))},745:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(737);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){Object(r.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}},819:function(e,t,n){"use strict";var r=n(23),a=n(59),o=n(2),c=n.n(o),l=n(80),i=n.n(l),s=n(562),u=n.n(s),d=n(569),f=["className","cssModule","tag"],p={tag:d.t,className:i.a.string,cssModule:i.a.object},h=function(e){var t=e.className,n=e.cssModule,o=e.tag,l=Object(a.a)(e,f),i=Object(d.p)(u()(t,"card-header"),n);return c.a.createElement(o,Object(r.a)({},l,{className:i}))};h.propTypes=p,h.defaultProps={tag:"div"},t.a=h}}]); |