@gov-cy/govcy-frontend-renderer 1.18.1 → 1.20.0

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.
@@ -2588,7 +2588,16 @@ t_30 += " ";
2588
2588
  t_30 += "\"";
2589
2589
  ;
2590
2590
  }
2591
- t_30 += ">\n ";
2591
+ t_30 += ">\n ";
2592
+ if(runtime.memberLookup((l_params),"name")) {
2593
+ t_30 += "<input type=\"hidden\" name=\"";
2594
+ t_30 += runtime.suppressValue(runtime.memberLookup((l_params),"name"), env.opts.autoescape);
2595
+ t_30 += "Attachment[fileId]\" value=\"\">\n <input type=\"hidden\" name=\"";
2596
+ t_30 += runtime.suppressValue(runtime.memberLookup((l_params),"name"), env.opts.autoescape);
2597
+ t_30 += "Attachment[sha256]\" value=\"\">";
2598
+ ;
2599
+ }
2600
+ t_30 += "\n ";
2592
2601
  ;
2593
2602
  frame = frame.pop();
2594
2603
  return new runtime.SafeString(t_30);
@@ -2682,7 +2691,7 @@ context.setVariable("hint", t_16);
2682
2691
  var t_17;
2683
2692
  t_17 = (function() {
2684
2693
  var output = "";
2685
- output += runtime.suppressValue((lineno = 18, colno = 41, runtime.callWrap(t_8, "govcyGetContent", context, ["fileView_view",runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2694
+ output += runtime.suppressValue((lineno = 21, colno = 41, runtime.callWrap(t_8, "govcyGetContent", context, ["fileView_view",runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2686
2695
  ;
2687
2696
  return output;
2688
2697
  })()
@@ -2697,7 +2706,7 @@ context.addExport("viewLabel", t_17);
2697
2706
  var t_18;
2698
2707
  t_18 = (function() {
2699
2708
  var output = "";
2700
- output += runtime.suppressValue((lineno = 19, colno = 43, runtime.callWrap(t_8, "govcyGetContent", context, ["fileView_delete",runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2709
+ output += runtime.suppressValue((lineno = 22, colno = 43, runtime.callWrap(t_8, "govcyGetContent", context, ["fileView_delete",runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2701
2710
  ;
2702
2711
  return output;
2703
2712
  })()
@@ -2718,7 +2727,7 @@ t_2 += "-view-control\" ";
2718
2727
  ;
2719
2728
  }
2720
2729
  t_2 += "class=\"govcy-form\">\n ";
2721
- t_2 += runtime.suppressValue((lineno = 23, colno = 23, runtime.callWrap(t_12, "formControl", context, [{"classes": runtime.memberLookup((l_params),"classes"),"lang": runtime.memberLookup((l_params),"lang")},runtime.makeKeywordArgs({"caller": (function (){var macro_t_19 = runtime.makeMacro(
2730
+ t_2 += runtime.suppressValue((lineno = 26, colno = 23, runtime.callWrap(t_12, "formControl", context, [{"classes": runtime.memberLookup((l_params),"classes"),"lang": runtime.memberLookup((l_params),"lang")},runtime.makeKeywordArgs({"caller": (function (){var macro_t_19 = runtime.makeMacro(
2722
2731
  [],
2723
2732
  [],
2724
2733
  function (kwargs) {
@@ -2735,7 +2744,7 @@ else {
2735
2744
  t_20 += "<p class=\"govcy-label govcy-label-primary\">";
2736
2745
  ;
2737
2746
  }
2738
- t_20 += runtime.suppressValue((lineno = 24, colno = 135, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"label"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2747
+ t_20 += runtime.suppressValue((lineno = 27, colno = 135, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"label"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2739
2748
  if(runtime.memberLookup((l_params),"isPageHeading")) {
2740
2749
  t_20 += "</h1>";
2741
2750
  ;
@@ -2744,7 +2753,7 @@ else {
2744
2753
  t_20 += "</p>";
2745
2754
  ;
2746
2755
  }
2747
- t_20 += runtime.suppressValue((lineno = 26, colno = 20, runtime.callWrap(t_16, "hint", context, [{"hint": runtime.memberLookup((l_params),"hint"),"lang": runtime.memberLookup((l_params),"lang")},runtime.makeKeywordArgs({"caller": (function (){var macro_t_21 = runtime.makeMacro(
2756
+ t_20 += runtime.suppressValue((lineno = 29, colno = 20, runtime.callWrap(t_16, "hint", context, [{"hint": runtime.memberLookup((l_params),"hint"),"lang": runtime.memberLookup((l_params),"lang")},runtime.makeKeywordArgs({"caller": (function (){var macro_t_21 = runtime.makeMacro(
2748
2757
  [],
2749
2758
  [],
2750
2759
  function (kwargs) {
@@ -2764,7 +2773,7 @@ t_20 += "\">";
2764
2773
  t_20 += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "viewLabel"), env.opts.autoescape);
2765
2774
  if(runtime.memberLookup((l_params),"visuallyHiddenText")) {
2766
2775
  t_20 += "<span class=\"govcy-visually-hidden\">";
2767
- t_20 += runtime.suppressValue((lineno = 28, colno = 146, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"visuallyHiddenText"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2776
+ t_20 += runtime.suppressValue((lineno = 31, colno = 146, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"visuallyHiddenText"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2768
2777
  t_20 += "</span>";
2769
2778
  ;
2770
2779
  }
@@ -2775,11 +2784,24 @@ t_20 += "\">";
2775
2784
  t_20 += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "deleteLabel"), env.opts.autoescape);
2776
2785
  if(runtime.memberLookup((l_params),"visuallyHiddenText")) {
2777
2786
  t_20 += "<span class=\"govcy-visually-hidden\">";
2778
- t_20 += runtime.suppressValue((lineno = 30, colno = 169, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"visuallyHiddenText"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2787
+ t_20 += runtime.suppressValue((lineno = 33, colno = 169, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"visuallyHiddenText"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
2779
2788
  t_20 += "</span>";
2780
2789
  ;
2781
2790
  }
2782
- t_20 += "</a>\n ";
2791
+ t_20 += "</a>\n ";
2792
+ if(runtime.memberLookup((l_params),"name") && runtime.memberLookup((l_params),"fileId") && runtime.memberLookup((l_params),"sha256")) {
2793
+ t_20 += "<input type=\"hidden\" name=\"";
2794
+ t_20 += runtime.suppressValue(runtime.memberLookup((l_params),"name"), env.opts.autoescape);
2795
+ t_20 += "Attachment[fileId]\" value=\"";
2796
+ t_20 += runtime.suppressValue(runtime.memberLookup((l_params),"fileId"), env.opts.autoescape);
2797
+ t_20 += "\">\n <input type=\"hidden\" name=\"";
2798
+ t_20 += runtime.suppressValue(runtime.memberLookup((l_params),"name"), env.opts.autoescape);
2799
+ t_20 += "Attachment[sha256]\" value=\"";
2800
+ t_20 += runtime.suppressValue(runtime.memberLookup((l_params),"sha256"), env.opts.autoescape);
2801
+ t_20 += "\">";
2802
+ ;
2803
+ }
2804
+ t_20 += "\n ";
2783
2805
  ;
2784
2806
  frame = frame.pop();
2785
2807
  return new runtime.SafeString(t_20);
@@ -2829,7 +2851,61 @@ kwargs = kwargs || {};
2829
2851
  if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {
2830
2852
  frame.set("caller", kwargs.caller); }
2831
2853
  frame.set("params", l_params);
2832
- var t_2 = "";t_2 += "<form ";
2854
+ var t_2 = "";if(runtime.memberLookup((l_params),"enctype") == "application") {
2855
+ var t_3;
2856
+ t_3 = "application/x-www-form-urlencoded";
2857
+ frame.set("enctype", t_3, true);
2858
+ if(frame.topLevel) {
2859
+ context.setVariable("enctype", t_3);
2860
+ }
2861
+ if(frame.topLevel) {
2862
+ context.addExport("enctype", t_3);
2863
+ }
2864
+ ;
2865
+ }
2866
+ else {
2867
+ if(runtime.memberLookup((l_params),"enctype") == "multipart") {
2868
+ var t_4;
2869
+ t_4 = "multipart/form-data";
2870
+ frame.set("enctype", t_4, true);
2871
+ if(frame.topLevel) {
2872
+ context.setVariable("enctype", t_4);
2873
+ }
2874
+ if(frame.topLevel) {
2875
+ context.addExport("enctype", t_4);
2876
+ }
2877
+ ;
2878
+ }
2879
+ else {
2880
+ if(runtime.memberLookup((l_params),"enctype") == "text") {
2881
+ var t_5;
2882
+ t_5 = "text/plain";
2883
+ frame.set("enctype", t_5, true);
2884
+ if(frame.topLevel) {
2885
+ context.setVariable("enctype", t_5);
2886
+ }
2887
+ if(frame.topLevel) {
2888
+ context.addExport("enctype", t_5);
2889
+ }
2890
+ ;
2891
+ }
2892
+ else {
2893
+ var t_6;
2894
+ t_6 = false;
2895
+ frame.set("enctype", t_6, true);
2896
+ if(frame.topLevel) {
2897
+ context.setVariable("enctype", t_6);
2898
+ }
2899
+ if(frame.topLevel) {
2900
+ context.addExport("enctype", t_6);
2901
+ }
2902
+ ;
2903
+ }
2904
+ ;
2905
+ }
2906
+ ;
2907
+ }
2908
+ t_2 += "<form ";
2833
2909
  if(runtime.memberLookup((l_params),"id")) {
2834
2910
  t_2 += "id=\"";
2835
2911
  t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"id"), env.opts.autoescape);
@@ -2842,6 +2918,12 @@ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"method"), env.opts
2842
2918
  t_2 += "\" ";
2843
2919
  ;
2844
2920
  }
2921
+ if(runtime.contextOrFrameLookup(context, frame, "enctype")) {
2922
+ t_2 += " enctype=\"";
2923
+ t_2 += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "enctype"), env.opts.autoescape);
2924
+ t_2 += "\" ";
2925
+ ;
2926
+ }
2845
2927
  t_2 += "action=\"";
2846
2928
  t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"action"), env.opts.autoescape);
2847
2929
  t_2 += "\" class=\"govcy-form";
@@ -2851,33 +2933,33 @@ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"classes"), env.opt
2851
2933
  ;
2852
2934
  }
2853
2935
  t_2 += "\" novalidate=\"\">\n ";
2854
- t_2 += runtime.suppressValue((lineno = 14, colno = 13, runtime.callWrap(runtime.contextOrFrameLookup(context, frame, "caller"), "caller", context, [])), env.opts.autoescape);
2936
+ t_2 += runtime.suppressValue((lineno = 28, colno = 13, runtime.callWrap(runtime.contextOrFrameLookup(context, frame, "caller"), "caller", context, [])), env.opts.autoescape);
2855
2937
  if(runtime.memberLookup((l_params),"elements")) {
2856
- env.getTemplate("govcyElement.njk", false, "elements/form.njk", false, function(t_4,t_3) {
2857
- if(t_4) { cb(t_4); return; }
2858
- t_3.getExported(function(t_5,t_3) {
2859
- if(t_5) { cb(t_5); return; }
2860
- if(Object.prototype.hasOwnProperty.call(t_3, "govcyElement")) {
2861
- var t_6 = t_3.govcyElement;
2938
+ env.getTemplate("govcyElement.njk", false, "elements/form.njk", false, function(t_8,t_7) {
2939
+ if(t_8) { cb(t_8); return; }
2940
+ t_7.getExported(function(t_9,t_7) {
2941
+ if(t_9) { cb(t_9); return; }
2942
+ if(Object.prototype.hasOwnProperty.call(t_7, "govcyElement")) {
2943
+ var t_10 = t_7.govcyElement;
2862
2944
  } else {
2863
2945
  cb(new Error("cannot import 'govcyElement'")); return;
2864
2946
  }
2865
- context.setVariable("govcyElement", t_6);
2947
+ context.setVariable("govcyElement", t_10);
2866
2948
  frame = frame.push();
2867
- var t_9 = runtime.memberLookup((l_params),"elements");
2868
- if(t_9) {t_9 = runtime.fromIterator(t_9);
2869
- var t_8 = t_9.length;
2870
- for(var t_7=0; t_7 < t_9.length; t_7++) {
2871
- var t_10 = t_9[t_7];
2872
- frame.set("element", t_10);
2873
- frame.set("loop.index", t_7 + 1);
2874
- frame.set("loop.index0", t_7);
2875
- frame.set("loop.revindex", t_8 - t_7);
2876
- frame.set("loop.revindex0", t_8 - t_7 - 1);
2877
- frame.set("loop.first", t_7 === 0);
2878
- frame.set("loop.last", t_7 === t_8 - 1);
2879
- frame.set("loop.length", t_8);
2880
- t_2 += runtime.suppressValue((lineno = 20, colno = 33, runtime.callWrap(t_6, "govcyElement", context, [runtime.memberLookup((t_10),"element"),runtime.memberLookup((t_10),"params"),runtime.makeKeywordArgs({"caller": (function (){var macro_t_11 = runtime.makeMacro(
2949
+ var t_13 = runtime.memberLookup((l_params),"elements");
2950
+ if(t_13) {t_13 = runtime.fromIterator(t_13);
2951
+ var t_12 = t_13.length;
2952
+ for(var t_11=0; t_11 < t_13.length; t_11++) {
2953
+ var t_14 = t_13[t_11];
2954
+ frame.set("element", t_14);
2955
+ frame.set("loop.index", t_11 + 1);
2956
+ frame.set("loop.index0", t_11);
2957
+ frame.set("loop.revindex", t_12 - t_11);
2958
+ frame.set("loop.revindex0", t_12 - t_11 - 1);
2959
+ frame.set("loop.first", t_11 === 0);
2960
+ frame.set("loop.last", t_11 === t_12 - 1);
2961
+ frame.set("loop.length", t_12);
2962
+ t_2 += runtime.suppressValue((lineno = 34, colno = 33, runtime.callWrap(t_10, "govcyElement", context, [runtime.memberLookup((t_14),"element"),runtime.memberLookup((t_14),"params"),runtime.makeKeywordArgs({"caller": (function (){var macro_t_15 = runtime.makeMacro(
2881
2963
  [],
2882
2964
  [],
2883
2965
  function (kwargs) {
@@ -2886,11 +2968,11 @@ frame = frame.push(true);
2886
2968
  kwargs = kwargs || {};
2887
2969
  if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {
2888
2970
  frame.set("caller", kwargs.caller); }
2889
- var t_12 = "";;
2971
+ var t_16 = "";;
2890
2972
  frame = frame.pop();
2891
- return new runtime.SafeString(t_12);
2973
+ return new runtime.SafeString(t_16);
2892
2974
  });
2893
- return macro_t_11;})()})])), env.opts.autoescape);
2975
+ return macro_t_15;})()})])), env.opts.autoescape);
2894
2976
  ;
2895
2977
  }
2896
2978
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gov-cy/govcy-frontend-renderer",
3
- "version": "1.18.1",
3
+ "version": "1.20.0",
4
4
  "description": "Render html for design elements of the Unified design system using njk or json template.",
5
5
  "author": "DMRID - DSF Team",
6
6
  "license": "MIT",
@@ -35,6 +35,10 @@
35
35
  {% call errorMessage({message:params.error,id:errorId, lang:params.lang}) %}{% endcall %}
36
36
  {#- render input -#}
37
37
  <input id="{{params.id}}"{% if params.name %} name="{{ params.name }}"{% endif %} type="file" class="govcy-file-upload"{% if params.hint or params.error%} aria-describedby="{% if params.hint %}{{hintId}} {% endif %}{% if params.error %}{{errorId}} {% endif %}"{% endif %}>
38
+ {% if params.name -%}
39
+ <input type="hidden" name="{{ params.name }}Attachment[fileId]" value="">
40
+ <input type="hidden" name="{{ params.name }}Attachment[sha256]" value="">
41
+ {%- endif %}
38
42
  {% endcall %}
39
43
  {%- endif -%}
40
44
  {%- endmacro %}
@@ -7,6 +7,9 @@
7
7
  @param {object} hint The hint text. Optional. Will escape text. `{en:"Content",el:"Περιεχομένο"}`
8
8
  @param {string} classes Additional classes to add to the outer div. Optional
9
9
  @param {boolean} isPageHeading Is the label also the page heading? Optional, default is false. Can be true,false
10
+ @param {string} name The input name. Will escape text. Optional
11
+ @param {string} fileId from upload response. Will escape text. Optional
12
+ @param {string} sha256 from upload response. Will escape text. Optional
10
13
  @param {string} lang The language used. Can be 'en','el'. Optional.
11
14
  @returns govcy file view and delete html
12
15
  #}
@@ -29,6 +32,10 @@
29
32
  <a href="{{ params.viewHref }}">{{viewLabel}}{%if params.visuallyHiddenText%}<span class="govcy-visually-hidden"> {{- govcyLocalizeContent(params.visuallyHiddenText, params.lang) -}}</span>{% endif %}</a>
30
33
  {#- render delete -#}
31
34
  <a class="govcy-ml-3" href="{{ params.deleteHref }}">{{deleteLabel}}{%if params.visuallyHiddenText%}<span class="govcy-visually-hidden"> {{- govcyLocalizeContent(params.visuallyHiddenText, params.lang) -}}</span>{% endif %}</a>
35
+ {% if params.name -%}
36
+ <input type="hidden" name="{{ params.name }}Attachment[fileId]" value="{{ params.fileId }}">
37
+ <input type="hidden" name="{{ params.name }}Attachment[sha256]" value="{{ params.sha256 }}">
38
+ {%- endif %}
32
39
  {% endcall %}
33
40
  </div>
34
41
  {%- endif -%}
@@ -3,6 +3,10 @@
3
3
  @param {string} id The hint id. Will escape text
4
4
  @param {string} classes Additional classes to add to the outer div. Optional
5
5
  @param {string} method The form method. Will escape text. Optional
6
+ @param {string} enctype The form enctype. Will escape text. Optional. Can be:
7
+ - `application`
8
+ - `multipart`
9
+ - `text`
6
10
  @param {array} elements If defined will be rendered elements inside the form.
7
11
  i.e. `[
8
12
  {element:"button",params:{text:{en:"Button 1",el:"Κουμπί 1"},lang:"en",id:"govcy-test-23b"} },
@@ -11,7 +15,17 @@
11
15
  @returns govcy form html
12
16
  #}
13
17
  {% macro form(params) -%}
14
- <form {% if params.id %}id="{{ params.id }}" {% endif %}{% if params.method %} method="{{ params.method }}" {% endif %}action="{{ params.action }}" class="govcy-form{% if params.classes %} {{ params.classes }}{% endif %}" novalidate="">
18
+ {#- set default values -#}
19
+ {%- if params.enctype=='application' -%}
20
+ {%- set enctype = 'application/x-www-form-urlencoded' -%}
21
+ {%- elif params.enctype=='multipart' -%}
22
+ {%- set enctype = 'multipart/form-data' -%}
23
+ {%- elif params.enctype=='text' -%}
24
+ {%- set enctype = 'text/plain' -%}
25
+ {%- else -%}
26
+ {%- set enctype = false -%}
27
+ {%- endif -%}
28
+ <form {% if params.id %}id="{{ params.id }}" {% endif %}{% if params.method %} method="{{ params.method }}" {% endif %}{% if enctype %} enctype="{{ enctype }}" {% endif %}action="{{ params.action }}" class="govcy-form{% if params.classes %} {{ params.classes }}{% endif %}" novalidate="">
15
29
  {{ caller() }}
16
30
  {#- if it has elements to be called -#}
17
31
  {%- if params.elements -%}