diff --git a/app/assets/stylesheets/direct_upload.css b/app/assets/stylesheets/direct_upload.css
new file mode 100644
index 00000000..d314bdf7
--- /dev/null
+++ b/app/assets/stylesheets/direct_upload.css
@@ -0,0 +1,37 @@
+.direct-upload {
+ display: inline-block;
+ position: relative;
+ padding: 2px 4px;
+ margin: 0 3px 3px 0;
+ border: 1px solid rgba(0, 0, 0, 0.3);
+ border-radius: 3px;
+ font-size: 11px;
+ line-height: 13px;
+}
+
+.direct-upload--pending {
+ opacity: 0.6;
+}
+
+.direct-upload__progress {
+ position: absolute;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ opacity: 0.2;
+ background: #0076ff;
+ transition: width 120ms ease-out, opacity 60ms 60ms ease-in;
+ transform: translate3d(0, 0, 0);
+}
+
+.direct-upload--complete .direct-upload__progress {
+ opacity: 0.4;
+}
+
+.direct-upload--error {
+ border-color: red;
+}
+
+input[type=file][data-direct-upload-url][disabled] {
+ display: none;
+}
diff --git a/app/controllers/apps/general_agenda_app/general_agenda_controller.rb b/app/controllers/apps/general_agenda_app/general_agenda_controller.rb
index 0a4d466d..c997b966 100644
--- a/app/controllers/apps/general_agenda_app/general_agenda_controller.rb
+++ b/app/controllers/apps/general_agenda_app/general_agenda_controller.rb
@@ -10,11 +10,13 @@ def index
text: params[:text_placeholder],
signed_required: params[:signed_required],
text_hint: params[:text_hint],
- attachments_template: params[:attachments],
+ attachments_template: params[:attachments] || [{name: 'Subor 1', description: 'Popis suboru 1', signed_required: '1'},{name: 'Subor 2', description: 'Popis suboru 1', signed_required: '0'}],
}.merge(general_agenda_params || {})
@application_form = Apps::GeneralAgendaApp::GeneralAgenda::ApplicationForm.new(attributes)
+ return render :invalid_template unless @application_form.valid_template?
+
redirect_to_upvs_submission if @application_form.is_submitted && @application_form.valid?
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 76d78d9e..022e948c 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -18,4 +18,10 @@ def sanitize_description(description, length: 500)
def dont_show_small_search_bar?
current_page?(root_path) || current_page?(search_path)
end
+
+ def localize_boolean(value)
+ value.to_s.in?(['1', 'true']) ? 'Áno' : 'Nie'
+ end
+
+ alias :lb :localize_boolean
end
diff --git a/app/models/apps/general_agenda_app/general_agenda/application_form.rb b/app/models/apps/general_agenda_app/general_agenda/application_form.rb
index 8ce1ec2f..fb41511e 100644
--- a/app/models/apps/general_agenda_app/general_agenda/application_form.rb
+++ b/app/models/apps/general_agenda_app/general_agenda/application_form.rb
@@ -26,6 +26,27 @@ class ApplicationForm
:is_submitted
)
+ def template_errors
+ @template_errors || []
+ end
+
+ def valid_template?
+ @template_errors = []
+
+ if attachments_template.present? && !attachments_template.is_a?(Array)
+ @template_errors << 'Premenná "attachments_template" musí byť pole súborov'
+ elsif attachments_template.is_a?(Array)
+ attachments_template.each_with_index do |attachment_template, index|
+ @template_errors << "Hodnota \"name\" pre #{index + 1} attachments_template musí byť povinne text" if attachment_template[:name].blank? || !attachment_template[:name].is_a?(String)
+ @template_errors << "Hodnota \"description\" pre #{index + 1} attachments_template má byť text" if attachment_template[:description].present? && !attachment_template[:description].is_a?(String)
+ @template_errors << "Hodnota \"required\" pre #{index + 1} attachments_template musí byť 1 alebo 0" unless attachment_template[:required].in?(['1', '0', nil])
+ @template_errors << "Hodnota \"signed_required\" pre #{index + 1} attachments_template musí byť 1 alebo 0" unless attachment_template[:signed_required].in?(['1', '0', nil])
+ end
+ end
+
+ @template_errors.blank?
+ end
+
private
def recipient_present?
diff --git a/app/views/apps/general_agenda_app/general_agenda/index.html.erb b/app/views/apps/general_agenda_app/general_agenda/index.html.erb
index dd41a851..acbeed80 100644
--- a/app/views/apps/general_agenda_app/general_agenda/index.html.erb
+++ b/app/views/apps/general_agenda_app/general_agenda/index.html.erb
@@ -49,6 +49,38 @@
+ <% if @application_form.attachments_template.present? %>
+
+ Prílohy
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%= attachment_template[:name] %>
+ <%= attachment_template[:description] %>
+
+ <%= lb attachment_template[:required] %>
+ <%= lb attachment_template[:signed_required] %>
+
+ <%= %>
+
+
+ <% end %>
+
+
+ <% end %>
+
Používaním tejto služby súhlasíte so spracovaním osobných údajov v rozsahu nevyhnutnom na odoslanie podania. Vaše údaje neukladáme, sú použité výlučne na vyplnenie podania.
@@ -170,4 +202,42 @@
(function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["accessibleAutocomplete"]=t():e["accessibleAutocomplete"]=t()})(window,function(){return function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/",o(o.s=37)}([function(e,t,n){var m=n(1),v=n(6),y=n(7),_=n(16),b=n(18),g="prototype",x=function(e,t,n){var r,o,i,u,l=e&x.F,a=e&x.G,s=e&x.S,c=e&x.P,p=e&x.B,f=a?m:s?m[t]||(m[t]={}):(m[t]||{})[g],d=a?v:v[t]||(v[t]={}),h=d[g]||(d[g]={});for(r in a&&(n=t),n)i=((o=!l&&f&&f[r]!==undefined)?f:n)[r],u=p&&o?b(i,m):c&&"function"==typeof i?b(Function.call,i):i,f&&_(f,r,i,e&x.U),d[r]!=i&&y(d,r,u),c&&h[r]!=i&&(h[r]=i)};m.core=v,x.F=1,x.G=2,x.S=4,x.P=8,x.B=16,x.W=32,x.U=64,x.R=128,e.exports=x},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){e.exports=!n(4)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t){e.exports=function(e){try{return!!e()}catch(t){return!0}}},function(e,t,n){"use strict";n.r(t),n.d(t,"h",function(){return r}),n.d(t,"createElement",function(){return r}),n.d(t,"cloneElement",function(){return i}),n.d(t,"Component",function(){return _}),n.d(t,"render",function(){return b}),n.d(t,"rerender",function(){return f}),n.d(t,"options",function(){return E});var a=function a(){},E={},s=[],c=[];function r(e,t){var n,r,o,i,u=c;for(i=arguments.length;2o;)u(r,n=t[o++])&&(~a(i,n)||i.push(n));return i}},function(e,t,n){var r=n(25),o=Math.max,i=Math.min;e.exports=function(e,t){return(e=r(e))<0?o(e+t,0):i(e,t)}},function(e,t){e.exports=!1},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(48);e.exports=function(e,t){return new(r(e))(t)}},function(e,t,n){var r=n(2),o=n(33),i=n(34)("species");e.exports=function(e){var t;return o(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!o(t.prototype)||(t=undefined),r(t)&&null===(t=t[i])&&(t=undefined)),t===undefined?Array:t}},function(e,t,n){"use strict";var r=n(0),o=n(32)(2);r(r.P+r.F*!n(13)([].filter,!0),"Array",{filter:function(e){return o(this,e,arguments[1])}})},function(e,t,n){var r=n(0);r(r.S,"Array",{isArray:n(33)})},function(e,t,n){"use strict";t.__esModule=!0,t["default"]=void 0,n(14),n(36),n(31),n(35),n(30),n(55),n(58);var $=n(5),H=o(n(60)),r=o(n(61));function o(e){return e&&e.__esModule?e:{"default":e}}function Q(){return(Q=Object.assign||function(e){for(var t=1;t=r;this.setState({query:l}),i||!a&&s&&c?o(l,function(e){var t=0=u,I=this.props.showNoOptionsFound&&S&&E&&N&&k,P=n+"__wrapper",M=n+"__input",j=null!==_?" "+M+"--focused":"",A=this.props.showAllValues?" "+M+"--show-all-values":" "+M+"--default",T=n+"__dropdown-arrow-down",L=-1!==_&&null!==_,B=n+"__menu",F=B+"--"+r,D=B+"--"+(g||I?"visible":"hidden"),R=n+"__option",U=n+"__hint",V=this.templateInputValue(x[O]),q=V&&0===V.toLowerCase().indexOf(w.toLowerCase())&&C?w+V.substr(w.length):"",W=z&&q;return c&&"string"==typeof(e=v({className:T}))&&(e=(0,$.createElement)("div",{className:n+"__dropdown-arrow-down-wrapper",dangerouslySetInnerHTML:{__html:e}})),(0,$.createElement)("div",{className:P,onKeyDown:this.handleKeyDown,role:"combobox","aria-expanded":g?"true":"false"},(0,$.createElement)(H["default"],{length:x.length,queryLength:w.length,minQueryLength:u,selectedOption:this.templateInputValue(x[O]),selectedOptionIndex:O,tQueryTooShort:f,tNoResults:d,tSelectedOption:h,tResults:m}),W&&(0,$.createElement)("span",null,(0,$.createElement)("input",{className:U,readonly:!0,tabIndex:"-1",value:q})),(0,$.createElement)("input",Q({"aria-activedescendant":!!L&&i+"__option--"+_,"aria-owns":i+"__listbox",autoComplete:"off",className:""+M+j+A,id:i,onClick:function(e){return o.handleInputClick(e)},onBlur:this.handleInputBlur},function K(e){return{onInput:e}}(this.handleInputChange),{onFocus:this.handleInputFocus,name:l,placeholder:a,ref:function(e){o.elementReferences[-1]=e},type:"text",role:"textbox",required:s,value:w})),e,(0,$.createElement)("ul",{className:B+" "+F+" "+D,onMouseLeave:function(e){return o.handleListMouseLeave(e)},id:i+"__listbox",role:"listbox"},x.map(function(e,t){var n=(-1===_?O===t:_===t)&&null===b?" "+R+"--focused":"",r=t%2?" "+R+"--odd":"";return(0,$.createElement)("li",{"aria-selected":_===t,className:""+R+n+r,dangerouslySetInnerHTML:{__html:o.templateSuggestion(e)},id:i+"__option--"+t,key:t,onBlur:function(e){return o.handleOptionBlur(e,t)},onClick:function(e){return o.handleOptionClick(e,t)},onMouseEnter:function(e){return o.handleOptionMouseEnter(e,t)},ref:function(e){o.elementReferences[t]=e},role:"option",tabIndex:"-1"})}),I&&(0,$.createElement)("li",{className:R+" "+R+"--no-results"},p())))},e}($.Component);(t["default"]=a).defaultProps={autoselect:!1,cssNamespace:"autocomplete",defaultValue:"",displayMenu:"inline",minLength:0,name:"input-autocomplete",placeholder:"",onConfirm:function(){},confirmOnBlur:!0,showNoOptionsFound:!0,showAllValues:!1,required:!1,tNoResults:function(){return"No results found"},dropdownArrow:r["default"]}},function(e,t,r){var o=r(9),i=r(53),u=r(28),l=r(26)("IE_PROTO"),a=function(){},s="prototype",c=function(){var e,t=r(15)("iframe"),n=u.length;for(t.style.display="none",r(54).appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("
diff --git a/app/views/apps/general_agenda_app/general_agenda/invalid_template.html.erb b/app/views/apps/general_agenda_app/general_agenda/invalid_template.html.erb
new file mode 100644
index 00000000..a6317fe4
--- /dev/null
+++ b/app/views/apps/general_agenda_app/general_agenda/invalid_template.html.erb
@@ -0,0 +1,14 @@
+<%= render partial: 'header' %>
+
+
+
+ Tento formulár nie je možné zobraziť
+
+
+
+ <% @application_form.template_errors.each do |msg| %>
+ <%= msg %>
+ <% end %>
+
+
+