| rev | 
   line source | 
| 
bsw/jbe@1309
 | 
     1 local initiative = param.get("initiative", "table")
 | 
| 
bsw/jbe@1309
 | 
     2 local direct_supporter
 | 
| 
bsw/jbe@1309
 | 
     3 if app.session.member_id then
 | 
| 
bsw/jbe@1309
 | 
     4   direct_supporter = initiative.issue.member_info.own_participation and initiative.member_info.supported
 | 
| 
bsw/jbe@1309
 | 
     5 end
 | 
| 
bsw/jbe@1309
 | 
     6 
 | 
| 
bsw/jbe@1309
 | 
     7 
 | 
| 
bsw@1649
 | 
     8 if direct_supporter then
 | 
| 
bsw@1649
 | 
     9   ui.tag{ tag = "dialog", attr = { id = "rating_dialog" }, content = function ()
 | 
| 
bsw@1649
 | 
    10 
 | 
| 
bsw@1649
 | 
    11     local opinion = {}
 | 
| 
bsw@1649
 | 
    12     ui.form { 
 | 
| 
bsw@1649
 | 
    13       attr = { onsubmit = "updateOpinion(); return false;" },
 | 
| 
bsw@1649
 | 
    14       module = "opinion", action = "update",
 | 
| 
bsw@1649
 | 
    15       routing = { default = {
 | 
| 
bsw@1649
 | 
    16         mode = "redirect", 
 | 
| 
bsw@1649
 | 
    17         module = "initiative", view = "show", id = initiative.id
 | 
| 
bsw@1649
 | 
    18       } },
 | 
| 
bsw@1649
 | 
    19       content = function ()
 | 
| 
bsw@1649
 | 
    20         ui.field.hidden{ attr = { id = "rating_suggestion_id" }, name = "suggestion_id" }        
 | 
| 
bsw@1649
 | 
    21         ui.container{ attr = { class = "opinon-question" }, content = _"Should the initiator implement this suggestion?" }
 | 
| 
bsw@1649
 | 
    22         ui.container { content = function ()
 | 
| 
bsw@1649
 | 
    23         
 | 
| 
bsw@1649
 | 
    24           local options = {
 | 
| 
bsw@1649
 | 
    25             { degree =  2, label = _"must" },
 | 
| 
bsw@1649
 | 
    26             { degree =  1, label = _"should" },
 | 
| 
bsw@1649
 | 
    27             { degree =  0, label = _"neutral" },
 | 
| 
bsw@1649
 | 
    28             { degree = -1, label = _"should not" },
 | 
| 
bsw@1649
 | 
    29             { degree = -2, label = _"must not" },
 | 
| 
bsw@1649
 | 
    30           }
 | 
| 
bsw@1649
 | 
    31           
 | 
| 
bsw@1649
 | 
    32           for i, option in ipairs(options) do
 | 
| 
bsw@1649
 | 
    33             ui.tag{
 | 
| 
bsw@1649
 | 
    34               tag = "label", 
 | 
| 
bsw@1649
 | 
    35               attr = { 
 | 
| 
bsw@1649
 | 
    36                 id = "rating_degree" .. option.degree,
 | 
| 
bsw@1649
 | 
    37                 class = "mdl-radio mdl-js-radio mdl-js-ripple-effect"
 | 
| 
bsw@1649
 | 
    38               }, 
 | 
| 
bsw@1649
 | 
    39               ["for"] = "rating_degree" .. option.degree, 
 | 
| 
bsw@1649
 | 
    40               content = function()
 | 
| 
bsw@1649
 | 
    41                 ui.tag{
 | 
| 
bsw@1649
 | 
    42                   tag = "input",
 | 
| 
bsw@1649
 | 
    43                   attr = {
 | 
| 
bsw@1649
 | 
    44                     class = "mdl-radio__button",
 | 
| 
bsw@1649
 | 
    45                     type = "radio",
 | 
| 
bsw@1649
 | 
    46                     name = "degree",
 | 
| 
bsw@1649
 | 
    47                     value = option.degree
 | 
| 
bsw@1649
 | 
    48                   }
 | 
| 
bsw@1649
 | 
    49                 }
 | 
| 
bsw@1649
 | 
    50                 ui.tag{
 | 
| 
bsw@1649
 | 
    51                   attr = { class = "mdl-radio__label" },
 | 
| 
bsw@1649
 | 
    52                   content = option.label
 | 
| 
bsw@1649
 | 
    53                 }
 | 
| 
bsw@1649
 | 
    54               end
 | 
| 
bsw@1649
 | 
    55             }
 | 
| 
bsw@1649
 | 
    56             slot.put("     ")
 | 
| 
bsw@1649
 | 
    57           end
 | 
| 
bsw@1649
 | 
    58         end }
 | 
| 
bsw@1649
 | 
    59         
 | 
| 
bsw@1649
 | 
    60         slot.put("<br />")
 | 
| 
bsw@1649
 | 
    61 
 | 
| 
bsw@1649
 | 
    62         ui.container{ attr = { class = "opinon-question" }, content = _"Did the initiator implement this suggestion?" }
 | 
| 
bsw@1649
 | 
    63         ui.container { content = function ()
 | 
| 
bsw@1649
 | 
    64 
 | 
| 
bsw@1649
 | 
    65           local options = {
 | 
| 
bsw@1649
 | 
    66             { degree = "false", id = "notfulfilled", label = _"No (not yet)" },
 | 
| 
bsw@1649
 | 
    67             { degree = "true", id = "fulfilled", label = _"Yes, it's implemented" },
 | 
| 
bsw@1649
 | 
    68           }
 | 
| 
bsw@1649
 | 
    69           
 | 
| 
bsw@1649
 | 
    70           for i, option in ipairs(options) do
 | 
| 
bsw@1649
 | 
    71             ui.tag{
 | 
| 
bsw@1649
 | 
    72               tag = "label", 
 | 
| 
bsw@1649
 | 
    73               attr = {
 | 
| 
bsw@1649
 | 
    74                 id = "rating_" .. option.id,
 | 
| 
bsw@1649
 | 
    75                 class = "mdl-radio mdl-js-radio mdl-js-ripple-effect"
 | 
| 
bsw@1649
 | 
    76               }, 
 | 
| 
bsw@1649
 | 
    77               ["for"] = "rating_" .. option.id, 
 | 
| 
bsw@1649
 | 
    78               content = function()
 | 
| 
bsw@1649
 | 
    79                 ui.tag{
 | 
| 
bsw@1649
 | 
    80                   tag = "input",
 | 
| 
bsw@1649
 | 
    81                   attr = {
 | 
| 
bsw@1649
 | 
    82                     class = "mdl-radio__button",
 | 
| 
bsw@1649
 | 
    83                     type = "radio",
 | 
| 
bsw@1649
 | 
    84                     name = "fulfilled",
 | 
| 
bsw@1649
 | 
    85                     value = option.degree,
 | 
| 
bsw@1649
 | 
    86                   }
 | 
| 
bsw@1649
 | 
    87                 }
 | 
| 
bsw@1649
 | 
    88                 ui.tag{
 | 
| 
bsw@1649
 | 
    89                   attr = { class = "mdl-radio__label" },
 | 
| 
bsw@1649
 | 
    90                   content = option.label
 | 
| 
bsw@1649
 | 
    91                 }
 | 
| 
bsw@1649
 | 
    92               end
 | 
| 
bsw@1649
 | 
    93             }
 | 
| 
bsw@1649
 | 
    94             slot.put("     ")
 | 
| 
bsw@1649
 | 
    95           end
 | 
| 
bsw@1649
 | 
    96         end }
 | 
| 
bsw@1649
 | 
    97     
 | 
| 
bsw@1649
 | 
    98         slot.put("<br />")
 | 
| 
bsw@1649
 | 
    99         
 | 
| 
bsw@1649
 | 
   100         ui.tag{
 | 
| 
bsw@1649
 | 
   101           tag = "input",
 | 
| 
bsw@1649
 | 
   102           attr = {
 | 
| 
bsw@1649
 | 
   103             type = "submit",
 | 
| 
bsw@1649
 | 
   104             class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
 | 
| 
bsw@1649
 | 
   105             value = _"publish my rating"
 | 
| 
bsw@1649
 | 
   106           },
 | 
| 
bsw@1649
 | 
   107           content = ""
 | 
| 
bsw@1649
 | 
   108         }
 | 
| 
bsw@1649
 | 
   109         
 | 
| 
bsw@1649
 | 
   110         slot.put("   ")
 | 
| 
bsw@1649
 | 
   111         
 | 
| 
bsw@1649
 | 
   112         ui.tag{
 | 
| 
bsw@1649
 | 
   113           tag = "input",
 | 
| 
bsw@1649
 | 
   114           attr = {
 | 
| 
bsw@1649
 | 
   115             onclick = "document.getElementById('rating_dialog').close(); return false;",
 | 
| 
bsw@1649
 | 
   116             type = "submit",
 | 
| 
bsw@1649
 | 
   117             class = "mdl-button mdl-js-button",
 | 
| 
bsw@1649
 | 
   118             value = _"cancel"
 | 
| 
bsw@1649
 | 
   119           },
 | 
| 
bsw@1649
 | 
   120           content = ""
 | 
| 
bsw@1649
 | 
   121         }
 | 
| 
bsw@1649
 | 
   122         
 | 
| 
bsw@1649
 | 
   123       end 
 | 
| 
bsw@1649
 | 
   124     }
 | 
| 
bsw@1649
 | 
   125 
 | 
| 
bsw@1649
 | 
   126   end }
 | 
| 
bsw@1649
 | 
   127 end
 | 
| 
bsw@1649
 | 
   128 
 | 
| 
bsw@1649
 | 
   129 
 | 
| 
bsw/jbe@1309
 | 
   130 ui.link { attr = { name = "suggestions" }, text = "" }
 | 
| 
bsw/jbe@1309
 | 
   131 
 | 
| 
bsw/jbe@1309
 | 
   132 ui.container {
 | 
| 
bsw/jbe@1309
 | 
   133   attr = { class = "section suggestions" },
 | 
| 
bsw/jbe@1309
 | 
   134   content = function ()
 | 
| 
bsw/jbe@1309
 | 
   135 
 | 
| 
bsw/jbe@1309
 | 
   136     if # ( initiative.suggestions ) > 0 then
 | 
| 
bsw/jbe@1309
 | 
   137   
 | 
| 
bsw/jbe@1309
 | 
   138       ui.heading { 
 | 
| 
bsw/jbe@1309
 | 
   139         level = 1, 
 | 
| 
bsw/jbe@1309
 | 
   140         content = _("Suggestions for improvement (#{count})", { count = # ( initiative.suggestions ) } ) 
 | 
| 
bsw/jbe@1309
 | 
   141       }
 | 
| 
bsw/jbe@1309
 | 
   142       ui.container { content = _"written and rated by the supportes of this initiative to improve the proposal and its reasons" }
 | 
| 
bsw/jbe@1309
 | 
   143       slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
   144       
 | 
| 
bsw/jbe@1309
 | 
   145       for i, suggestion in ipairs(initiative.suggestions) do
 | 
| 
bsw/jbe@1309
 | 
   146         
 | 
| 
bsw/jbe@1309
 | 
   147         local opinion = Opinion:by_pk(app.session.member_id, suggestion.id)
 | 
| 
bsw/jbe@1309
 | 
   148 
 | 
| 
bsw/jbe@1309
 | 
   149         local class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp not-folded"
 | 
| 
bsw/jbe@1309
 | 
   150         if suggestion.id == param.get("suggestion_id", atom.number) then
 | 
| 
bsw/jbe@1309
 | 
   151           class = class .. " highlighted"
 | 
| 
bsw/jbe@1309
 | 
   152         end
 | 
| 
bsw/jbe@1309
 | 
   153         if member and not initiative.issue.fully_frozen and not initiative.issue.closed and initiative.member_info.supported then
 | 
| 
bsw/jbe@1309
 | 
   154           class = class .. " rateable"
 | 
| 
bsw/jbe@1309
 | 
   155         end
 | 
| 
bsw/jbe@1309
 | 
   156       
 | 
| 
bsw/jbe@1309
 | 
   157         ui.link { attr = { name = "s" .. suggestion.id }, text = "" }
 | 
| 
bsw/jbe@1309
 | 
   158         ui.tag { tag = "div", attr = { class = class, id = "s" .. suggestion.id }, content = function ()
 | 
| 
bsw/jbe@1309
 | 
   159           ui.tag{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   160             ui.heading { level = 2, 
 | 
| 
bsw/jbe@1309
 | 
   161               attr = { class = "mdl-card__title-text" },
 | 
| 
bsw@1649
 | 
   162               content = function()
 | 
| 
bsw@1649
 | 
   163                 ui.tag{ content = format.string(suggestion.name, {
 | 
| 
bsw@1649
 | 
   164                   truncate_at = 160, truncate_suffix = true })
 | 
| 
bsw/jbe@1309
 | 
   165                 }
 | 
| 
bsw@1649
 | 
   166               end
 | 
| 
bsw@1649
 | 
   167             }
 | 
| 
bsw@1649
 | 
   168           end }
 | 
| 
bsw/jbe@1309
 | 
   169 
 | 
| 
bsw@1649
 | 
   170             
 | 
| 
bsw/jbe@1309
 | 
   171       
 | 
| 
bsw/jbe@1309
 | 
   172           ui.container{ attr = { class = "suggestion-content" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   173         
 | 
| 
bsw/jbe@1309
 | 
   174             ui.container { 
 | 
| 
bsw/jbe@1309
 | 
   175               attr = { class = "mdl-card__content mdl-card--border suggestionInfo" },
 | 
| 
bsw/jbe@1309
 | 
   176               content = function ()
 | 
| 
bsw/jbe@1309
 | 
   177               
 | 
| 
bsw/jbe@1309
 | 
   178                 if app.session:has_access("authors_pseudonymous") then
 | 
| 
bsw@1658
 | 
   179                   ui.tag{ content = _"by" }
 | 
| 
bsw@1658
 | 
   180                   slot.put(" ")
 | 
| 
bsw@1658
 | 
   181                   ui.link{
 | 
| 
bsw@1658
 | 
   182                     module = "member", view = "show", id = suggestion.author_id,
 | 
| 
bsw@1658
 | 
   183                     content = suggestion.author.name
 | 
| 
bsw@1658
 | 
   184                   }
 | 
| 
bsw/jbe@1309
 | 
   185                 end
 | 
| 
bsw/jbe@1309
 | 
   186                 
 | 
| 
bsw@1649
 | 
   187                 execute.view{
 | 
| 
bsw@1649
 | 
   188                   module = "suggestion", view = "_collective_rating", params = {
 | 
| 
bsw@1649
 | 
   189                     suggestion = suggestion
 | 
| 
bsw@1649
 | 
   190                   }
 | 
| 
bsw@1649
 | 
   191                 }
 | 
| 
bsw/jbe@1309
 | 
   192 
 | 
| 
bsw/jbe@1309
 | 
   193               end 
 | 
| 
bsw/jbe@1309
 | 
   194             }
 | 
| 
bsw/jbe@1309
 | 
   195                 
 | 
| 
bsw/jbe@1309
 | 
   196             ui.container {
 | 
| 
bsw@1649
 | 
   197               attr = { class = "mdl-card__content suggestion-text draft" },
 | 
| 
bsw/jbe@1309
 | 
   198               content = function ()
 | 
| 
bsw/jbe@1309
 | 
   199                 slot.put ( suggestion:get_content( "html" ) )
 | 
| 
bsw@1649
 | 
   200 
 | 
| 
bsw@1649
 | 
   201                 ui.container { attr = { class = "floatx-right" }, content = function()
 | 
| 
bsw@1649
 | 
   202                 
 | 
| 
bsw@1649
 | 
   203                   ui.link { 
 | 
| 
bsw@1649
 | 
   204                     attr = { 
 | 
| 
bsw@1649
 | 
   205                       class = "mdl-button mdl-js-button mdl-button--icon suggestion-more",
 | 
| 
bsw@1649
 | 
   206                       onclick = "document.querySelector('#s" .. suggestion.id .. "').classList.remove('folded');document.querySelector('#s" .. suggestion.id .. "').classList.add('unfolded'); return false;"
 | 
| 
bsw@1649
 | 
   207                     },
 | 
| 
bsw@1649
 | 
   208                     content = function()
 | 
| 
bsw@1649
 | 
   209                       ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "expand_more" }
 | 
| 
bsw@1649
 | 
   210                     end
 | 
| 
bsw@1649
 | 
   211                   }
 | 
| 
bsw@1649
 | 
   212                   
 | 
| 
bsw@1649
 | 
   213                   ui.link { 
 | 
| 
bsw@1649
 | 
   214                     attr = { 
 | 
| 
bsw@1649
 | 
   215                       class = "mdl-button mdl-js-button mdl-button--icon suggestion-less",
 | 
| 
bsw@1649
 | 
   216                       onclick = "document.querySelector('#s" .. suggestion.id .. "').classList.add('folded');document.querySelector('#s" .. suggestion.id .. "').classList.remove('unfolded'); return false;"
 | 
| 
bsw@1649
 | 
   217                     },
 | 
| 
bsw@1649
 | 
   218                     content = function()
 | 
| 
bsw@1649
 | 
   219                       ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "expand_less" }
 | 
| 
bsw@1649
 | 
   220                     end
 | 
| 
bsw@1649
 | 
   221                   }
 | 
| 
bsw@1649
 | 
   222                   --[[
 | 
| 
bsw@1649
 | 
   223                   ui.link{
 | 
| 
bsw@1649
 | 
   224                     attr = { class = "mdl-button" },
 | 
| 
bsw@1649
 | 
   225                     content = _"Details",
 | 
| 
bsw@1649
 | 
   226                     module = "suggestion", view = "show", id = suggestion.id
 | 
| 
bsw@1649
 | 
   227                   }
 | 
| 
bsw@1649
 | 
   228                   --]]
 | 
| 
bsw@1649
 | 
   229                 end }
 | 
| 
bsw/jbe@1309
 | 
   230                
 | 
| 
bsw/jbe@1309
 | 
   231               end
 | 
| 
bsw/jbe@1309
 | 
   232             }
 | 
| 
bsw/jbe@1309
 | 
   233  
 | 
| 
bsw/jbe@1309
 | 
   234           end }
 | 
| 
bsw/jbe@1309
 | 
   235 
 | 
| 
bsw@1649
 | 
   236           ui.container { attr = { class = "mdl-card__actions mdl-card--border" }, content = function()
 | 
| 
bsw@1649
 | 
   237 
 | 
| 
bsw@1658
 | 
   238             if direct_supporter then
 | 
| 
bsw@1658
 | 
   239               ui.container{ attr = { class = "suggestion_rating_info" }, content = function()
 | 
| 
bsw@1658
 | 
   240                 ui.tag{ attr = { id = "s" .. suggestion.id .. "_rating_text" }, content = function()
 | 
| 
bsw@1658
 | 
   241                   local text = ""
 | 
| 
bsw@1658
 | 
   242                   if opinion then
 | 
| 
bsw@1658
 | 
   243                     if opinion.degree == 2 then
 | 
| 
bsw@1658
 | 
   244                       text = _"must"
 | 
| 
bsw@1658
 | 
   245                     elseif opinion.degree == 1 then
 | 
| 
bsw@1658
 | 
   246                       text = _"should"
 | 
| 
bsw@1658
 | 
   247                     elseif opinion.degree == 0 then
 | 
| 
bsw@1658
 | 
   248                       text = _"neutral"
 | 
| 
bsw@1658
 | 
   249                     elseif opinion.degree == -1 then
 | 
| 
bsw@1658
 | 
   250                       text = _"should not"
 | 
| 
bsw@1658
 | 
   251                     elseif opinion.degree == -2 then
 | 
| 
bsw@1658
 | 
   252                       text = _"must not"
 | 
| 
bsw@1658
 | 
   253                     end
 | 
| 
bsw@1658
 | 
   254                     ui.tag { content = text }
 | 
| 
bsw@1658
 | 
   255                     slot.put ( " " )
 | 
| 
bsw@1658
 | 
   256                     if 
 | 
| 
bsw@1658
 | 
   257                       (opinion.degree > 0 and not opinion.fulfilled)
 | 
| 
bsw@1658
 | 
   258                       or (opinion.degree < 0 and opinion.fulfilled)
 | 
| 
bsw@1658
 | 
   259                     then
 | 
| 
bsw@1658
 | 
   260                       ui.tag{ content = _"but" }
 | 
| 
bsw@1658
 | 
   261                     else
 | 
| 
bsw@1658
 | 
   262                       ui.tag{ content = _"and" }
 | 
| 
bsw@1658
 | 
   263                     end
 | 
| 
bsw@1658
 | 
   264                     slot.put ( " " )
 | 
| 
bsw@1658
 | 
   265                     local text = ""
 | 
| 
bsw@1658
 | 
   266                     if opinion.fulfilled then
 | 
| 
bsw@1658
 | 
   267                       text = _"is implemented"
 | 
| 
bsw@1658
 | 
   268                     else
 | 
| 
bsw@1658
 | 
   269                       text = _"is not implemented"
 | 
| 
bsw@1658
 | 
   270                     end
 | 
| 
bsw@1658
 | 
   271                     ui.tag { content = text }
 | 
| 
bsw@1649
 | 
   272                   end
 | 
| 
bsw@1658
 | 
   273                 end }
 | 
| 
bsw@1658
 | 
   274                 local id = "s" .. suggestion.id .. "_rating_icon"
 | 
| 
bsw@1658
 | 
   275                 if opinion and (
 | 
| 
bsw@1649
 | 
   276                     (opinion.degree > 0 and not opinion.fulfilled)
 | 
| 
bsw@1649
 | 
   277                     or (opinion.degree < 0 and opinion.fulfilled)
 | 
| 
bsw@1658
 | 
   278                   )
 | 
| 
bsw@1658
 | 
   279                 then
 | 
| 
bsw@1658
 | 
   280                   slot.put(" ")
 | 
| 
bsw@1658
 | 
   281                   if math.abs(opinion.degree) > 1 then
 | 
| 
bsw@1658
 | 
   282                     ui.icon("warning", "red", id)
 | 
| 
bsw@1649
 | 
   283                   else
 | 
| 
bsw@1658
 | 
   284                     ui.icon("warning", nil, id)
 | 
| 
bsw@1649
 | 
   285                   end
 | 
| 
bsw@1658
 | 
   286                 elseif opinion then
 | 
| 
bsw@1658
 | 
   287                   slot.put(" ")
 | 
| 
bsw@1658
 | 
   288                   ui.icon("done", nil, id)
 | 
| 
bsw@1658
 | 
   289                 else
 | 
| 
bsw@1658
 | 
   290                   slot.put(" ")
 | 
| 
bsw@1658
 | 
   291                   ui.icon("blank", nil, id)
 | 
| 
bsw@1649
 | 
   292                 end
 | 
| 
bsw@1649
 | 
   293               end }
 | 
| 
bsw@1658
 | 
   294               
 | 
| 
bsw@1658
 | 
   295               ui.link{
 | 
| 
bsw@1658
 | 
   296                 attr = {
 | 
| 
bsw@1658
 | 
   297                   id = "s" .. suggestion.id .. "_rate_button",
 | 
| 
bsw@1658
 | 
   298                   class = "mdl-button",
 | 
| 
bsw@1658
 | 
   299                   onclick = "rateSuggestion(" .. suggestion.id .. ", " .. (opinion and opinion.degree or 0) .. ", " .. (opinion and (opinion.fulfilled and "true" or "false") or "null") .. ");return false;"
 | 
| 
bsw@1658
 | 
   300                 },
 | 
| 
bsw@1658
 | 
   301                 content = function()
 | 
| 
bsw@1658
 | 
   302                   if opinion then
 | 
| 
bsw@1658
 | 
   303                     ui.tag { content = _"update rating" }
 | 
| 
bsw@1658
 | 
   304                   else
 | 
| 
bsw@1658
 | 
   305                     ui.tag { content = _"rate suggestion" }
 | 
| 
bsw@1658
 | 
   306                   end
 | 
| 
bsw@1649
 | 
   307                 end
 | 
| 
bsw@1658
 | 
   308               }
 | 
| 
bsw@1658
 | 
   309             end
 | 
| 
bsw@1658
 | 
   310                       
 | 
| 
bsw/jbe@1309
 | 
   311             ui.link{
 | 
| 
bsw/jbe@1309
 | 
   312               attr = { class = "mdl-button" },
 | 
| 
bsw/jbe@1309
 | 
   313               content = _"Details",
 | 
| 
bsw/jbe@1309
 | 
   314               module = "suggestion", view = "show", id = suggestion.id
 | 
| 
bsw/jbe@1309
 | 
   315             }
 | 
| 
bsw@1649
 | 
   316 
 | 
| 
bsw/jbe@1309
 | 
   317           end }
 | 
| 
bsw/jbe@1309
 | 
   318           ui.script{ script = [[
 | 
| 
bsw@1649
 | 
   319             var rateSuggestionRateText = "]] .. _"rate suggestion" .. [[";
 | 
| 
bsw@1649
 | 
   320             var rateSuggestionUpdateRatingText = "]] .. _"update rating" .. [[";
 | 
| 
bsw@1649
 | 
   321             var rateSuggestionDegreeTexts = {
 | 
| 
bsw@1649
 | 
   322               "-2": "]] .. _"must not" .. [[",
 | 
| 
bsw@1649
 | 
   323               "-1": "]] .. _"should not" .. [[",
 | 
| 
bsw@1649
 | 
   324               "1": "]] .. _"should" .. [[",
 | 
| 
bsw@1649
 | 
   325               "2": "]] .. _"must" .. [["
 | 
| 
bsw@1649
 | 
   326             }
 | 
| 
bsw@1649
 | 
   327             var rateSuggestionAndText = "]] .. _"and" .. [[";
 | 
| 
bsw@1649
 | 
   328             var rateSuggestionButText = "]] .. _"but" .. [[";
 | 
| 
bsw@1649
 | 
   329             var rateSuggestionFulfilledText = "]] .. _"is implemented" .. [[";
 | 
| 
bsw@1649
 | 
   330             var rateSuggestionNotFulfilledText = "]] .. _"is not implemented" .. [[";
 | 
| 
bsw/jbe@1309
 | 
   331             window.addEventListener("load", function() {
 | 
| 
bsw/jbe@1309
 | 
   332               var textEl = document.querySelector('#s]] .. suggestion.id .. [[ .suggestion-content');
 | 
| 
bsw/jbe@1309
 | 
   333               var height = textEl.clientHeight;
 | 
| 
bsw@1649
 | 
   334               if (height > 250) {
 | 
| 
bsw/jbe@1309
 | 
   335                 document.querySelector('#s]] .. suggestion.id .. [[').classList.add('folded');
 | 
| 
bsw/jbe@1309
 | 
   336               }
 | 
| 
bsw/jbe@1309
 | 
   337             });
 | 
| 
bsw/jbe@1309
 | 
   338           ]] }
 | 
| 
bsw/jbe@1309
 | 
   339           
 | 
| 
bsw/jbe@1309
 | 
   340         end } 
 | 
| 
bsw/jbe@1309
 | 
   341 
 | 
| 
bsw/jbe@1309
 | 
   342       end -- for i, suggestion
 | 
| 
bsw/jbe@1309
 | 
   343     
 | 
| 
bsw/jbe@1309
 | 
   344     end -- if #initiative.suggestions > 0
 | 
| 
bsw/jbe@1309
 | 
   345   end
 | 
| 
bsw/jbe@1309
 | 
   346 }
 |