(window.webpackJsonp=window.webpackJsonp||[]).push([[46],{2192:function(t,e,n){"use strict";n.r(e);n(2),n(40),n(31),n(49),n(34),n(26),n(10),n(50),n(54),n(39);var r=n(27),l=(n(82),n(4),n(8),n(5)),o=n(51),c=n.n(o),v=n(173),f=n.n(v),d=n(56),m=n(172);function y(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return O(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return O(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,o=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){c=!0,l=t},f:function(){try{o||null==n.return||n.return()}finally{if(c)throw l}}}}function O(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var h=Object(l.c)({props:{tags:Array,rules:Object},setup:function(t,e){var title=Object(l.i)(""),n=Object(l.i)("normal"),o=Object(l.i)(["","","","",""]),v=Object(l.i)(!1),O=Object(l.a)((function(){var e=!0;if(v.value){var n,r,l=y(null===(n=t.rules)||void 0===n?void 0:n.options);try{for(l.s();!(r=l.n()).done;){var c=r.value;if(!e)break;e=c(o.value)}}catch(t){l.e(t)}finally{l.f()}}return e})),h=[{text:c()("systems.polls.normal"),value:"normal",disabled:!1},{text:c()("systems.polls.tips"),value:"tips",disabled:!1},{text:c()("systems.polls.numbers"),value:"numbers",disabled:!1},{text:c()("systems.polls.bits"),value:"bits",disabled:!1}],w=Object(l.i)(!1),j=Object(l.i)(!0),form=Object(l.i)(null),x=function(){var t=Object(r.a)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(v.value=!0,!form.value.validate()||!0!==O.value){t.next=5;break}return w.value=!0,t.next=5,new Promise((function(t){var r={id:Object(m.a)(),type:n.value,title:title.value,options:o.value.filter((function(t){return t.length>0})),openedAt:(new Date).toISOString()};console.log("Saving",{item:r}),f.a.post("/api/systems/polls",r,{headers:{authorization:"Bearer ".concat(localStorage.accessToken)}}).then((function(){t(!0),e.emit("save"),w.value=!1}))}));case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return{translate:c.a,title:title,type:n,typeItems:h,newItemSaving:w,newItem:x,valid:j,closeDlg:function(){e.emit("close")},form:form,capitalize:d.capitalize,options:o,validOptions:O,isDirtyOptions:v}}}),w=h,j=n(46),x=n(44),k=n.n(x),S=n(52),I=n(377),A=n(263),_=n(139),component=Object(j.a)(w,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("v-form",{ref:"form",attrs:{"lazy-validation":""},model:{value:t.valid,callback:function(e){t.valid=e},expression:"valid"}},[n("v-text-field",{attrs:{label:t.capitalize(t.translate("systems.polls.title")),rules:t.rules.title,"hide-details":"auto",required:"",counter:""},model:{value:t.title,callback:function(e){t.title=e},expression:"title"}}),t._v(" "),n("v-select",{attrs:{items:t.typeItems,label:t.capitalize(t.translate("systems.polls.votingBy")),"return-object":!1},model:{value:t.type,callback:function(e){t.type=e},expression:"type"}}),t._v(" "),t._l(t.options,(function(option,e){return n("v-text-field",{key:"poll-option-"+e,class:{"pa-0":e>0},attrs:{label:"Answer "+String(e+1),"hide-details":"auto",counter:"",error:t.isDirtyOptions&&!0!==t.validOptions,"error-messages":"string"==typeof t.validOptions&&t.validOptions.length>0&&4===e?[t.validOptions]:void 0},on:{keypress:function(e){t.isDirtyOptions=!0}},model:{value:t.options[e],callback:function(n){t.$set(t.options,e,n)},expression:"options[index]"}})})),t._v(" "),n("v-btn",{staticClass:"mr-4",attrs:{loading:t.newItemSaving,disabled:!t.valid&&!0!==t.validOptions},on:{click:t.newItem}},[t._v("\n    submit\n  ")]),t._v(" "),n("v-btn",{staticClass:"mr-4",on:{click:t.closeDlg}},[t._v("\n    close\n  ")])],2)}),[],!1,null,null,null);e.default=component.exports;k()(component,{VBtn:S.a,VForm:I.a,VSelect:A.a,VTextField:_.a})}}]);