| rev | 
   line source | 
| 
bsw/jbe@4
 | 
     1 
 | 
| 
bsw/jbe@4
 | 
     2 local initiative = param.get("initiative", "table")
 | 
| 
bsw/jbe@0
 | 
     3 local suggestions_selector = param.get("suggestions_selector", "table")
 | 
| 
bsw/jbe@19
 | 
     4 local tab_id = param.get("tab_id")
 | 
| 
bsw/jbe@19
 | 
     5 local show_name = param.get("show_name", atom.boolean)
 | 
| 
bsw/jbe@19
 | 
     6 if show_name == nil then
 | 
| 
bsw/jbe@19
 | 
     7   show_name = true
 | 
| 
bsw/jbe@19
 | 
     8 end
 | 
| 
bsw/jbe@19
 | 
     9 local show_filter = param.get("show_filter", atom.boolean)
 | 
| 
bsw/jbe@19
 | 
    10 if show_filter == nil then
 | 
| 
bsw/jbe@19
 | 
    11   show_filter = true
 | 
| 
bsw/jbe@19
 | 
    12 end
 | 
| 
bsw/jbe@0
 | 
    13 
 | 
| 
bsw/jbe@19
 | 
    14 local partial = {
 | 
| 
bsw/jbe@19
 | 
    15   routing = {
 | 
| 
bsw/jbe@19
 | 
    16     default = {
 | 
| 
bsw/jbe@19
 | 
    17       mode = "redirect",
 | 
| 
bsw/jbe@19
 | 
    18       module = "initiative",
 | 
| 
bsw/jbe@19
 | 
    19       view = "show_tab",
 | 
| 
bsw/jbe@19
 | 
    20       params = {
 | 
| 
bsw/jbe@19
 | 
    21         initiative_id = initiative.id,
 | 
| 
bsw/jbe@19
 | 
    22         tab = "suggestions",
 | 
| 
bsw/jbe@19
 | 
    23         tab_id = tab_id
 | 
| 
bsw/jbe@19
 | 
    24       },
 | 
| 
bsw/jbe@19
 | 
    25     }
 | 
| 
bsw/jbe@19
 | 
    26   }
 | 
| 
bsw/jbe@19
 | 
    27 }
 | 
| 
bsw/jbe@19
 | 
    28 
 | 
| 
bsw/jbe@19
 | 
    29 local ui_filters = ui.filters
 | 
| 
bsw/jbe@19
 | 
    30 if not show_filter then
 | 
| 
bsw/jbe@19
 | 
    31   ui_filters = function(args) args.content() end
 | 
| 
bsw/jbe@19
 | 
    32 end
 | 
| 
bsw/jbe@19
 | 
    33 
 | 
| 
bsw/jbe@19
 | 
    34 ui_filters{
 | 
| 
bsw/jbe@19
 | 
    35   label = _"Show filter",
 | 
| 
bsw/jbe@0
 | 
    36   selector = suggestions_selector,
 | 
| 
bsw/jbe@19
 | 
    37   {
 | 
| 
bsw/jbe@19
 | 
    38     label = _"Order by",
 | 
| 
bsw/jbe@4
 | 
    39     {
 | 
| 
bsw/jbe@19
 | 
    40       name = "plus_unfulfilled",
 | 
| 
bsw/jbe@19
 | 
    41       label = _"requested",
 | 
| 
bsw/jbe@19
 | 
    42       selector_modifier = function(selector) selector:add_order_by("plus2_unfulfilled_count + plus1_unfulfilled_count DESC, id") end
 | 
| 
bsw/jbe@4
 | 
    43     },
 | 
| 
bsw/jbe@4
 | 
    44     {
 | 
| 
bsw/jbe@4
 | 
    45       name = "plus2",
 | 
| 
bsw/jbe@4
 | 
    46       label = _"must",
 | 
| 
bsw/jbe@19
 | 
    47       selector_modifier = function(selector) selector:add_order_by("plus2_unfulfilled_count + plus2_fulfilled_count DESC, id") end
 | 
| 
bsw/jbe@4
 | 
    48     },
 | 
| 
bsw/jbe@4
 | 
    49     {
 | 
| 
bsw/jbe@4
 | 
    50       name = "plus",
 | 
| 
bsw/jbe@4
 | 
    51       label = _"must/should",
 | 
| 
bsw/jbe@19
 | 
    52       selector_modifier = function(selector) selector:add_order_by("plus2_unfulfilled_count + plus1_unfulfilled_count + plus2_fulfilled_count + plus1_fulfilled_count DESC, id") end
 | 
| 
bsw/jbe@4
 | 
    53     },
 | 
| 
bsw/jbe@4
 | 
    54     {
 | 
| 
bsw/jbe@4
 | 
    55       name = "minus",
 | 
| 
bsw/jbe@4
 | 
    56       label = _"must/should not",
 | 
| 
bsw/jbe@19
 | 
    57       selector_modifier = function(selector) selector:add_order_by("minus2_unfulfilled_count + minus1_unfulfilled_count + minus2_fulfilled_count + minus1_fulfilled_count DESC, id") end
 | 
| 
bsw/jbe@4
 | 
    58     },
 | 
| 
bsw/jbe@4
 | 
    59     {
 | 
| 
bsw/jbe@4
 | 
    60       name = "minus2",
 | 
| 
bsw/jbe@4
 | 
    61       label = _"must not",
 | 
| 
bsw/jbe@19
 | 
    62       selector_modifier = function(selector) selector:add_order_by("minus2_unfulfilled_count + minus2_fulfilled_count DESC, id") end
 | 
| 
bsw/jbe@19
 | 
    63     }
 | 
| 
bsw/jbe@4
 | 
    64   },
 | 
| 
bsw/jbe@0
 | 
    65   content = function()
 | 
| 
bsw/jbe@4
 | 
    66     ui.paginate{
 | 
| 
bsw/jbe@4
 | 
    67       selector = suggestions_selector,
 | 
| 
bsw/jbe@4
 | 
    68       content = function()
 | 
| 
bsw/jbe@4
 | 
    69         ui.list{
 | 
| 
bsw/jbe@4
 | 
    70           attr = { style = "table-layout: fixed;" },
 | 
| 
bsw/jbe@4
 | 
    71           records = suggestions_selector:exec(),
 | 
| 
bsw/jbe@4
 | 
    72           columns = {
 | 
| 
bsw/jbe@4
 | 
    73             {
 | 
| 
bsw/jbe@19
 | 
    74               label = show_name and _"Suggestion" or nil,
 | 
| 
bsw/jbe@4
 | 
    75               content = function(record)
 | 
| 
bsw/jbe@19
 | 
    76                 if show_name then
 | 
| 
bsw/jbe@19
 | 
    77                   ui.link{
 | 
| 
bsw/jbe@19
 | 
    78                     text = record.name,
 | 
| 
bsw/jbe@19
 | 
    79                     module = "suggestion",
 | 
| 
bsw/jbe@19
 | 
    80                     view = "show",
 | 
| 
bsw/jbe@19
 | 
    81                     id = record.id
 | 
| 
bsw/jbe@19
 | 
    82                   }
 | 
| 
bsw/jbe@19
 | 
    83                 end
 | 
| 
bsw/jbe@4
 | 
    84               end
 | 
| 
bsw/jbe@4
 | 
    85             },
 | 
| 
bsw/jbe@4
 | 
    86             {
 | 
| 
bsw@95
 | 
    87               label = _"Collective opinion of supporters",
 | 
| 
bsw/jbe@4
 | 
    88               label_attr = { style = "width: 101px;" },
 | 
| 
bsw/jbe@4
 | 
    89               content = function(record)
 | 
| 
bsw/jbe@4
 | 
    90                 if record.minus2_unfulfilled_count then
 | 
| 
bsw@95
 | 
    91                   local max_value = record.initiative.supporter_count
 | 
| 
bsw/jbe@4
 | 
    92                   ui.bargraph{
 | 
| 
bsw/jbe@4
 | 
    93                     max_value = max_value,
 | 
| 
bsw@95
 | 
    94                     width = 100,
 | 
| 
bsw/jbe@4
 | 
    95                     bars = {
 | 
| 
bsw@95
 | 
    96                       { color = "#0a0", value = record.plus2_unfulfilled_count + record.plus2_fulfilled_count },
 | 
| 
bsw@95
 | 
    97                       { color = "#8f8", value = record.plus1_unfulfilled_count + record.plus1_fulfilled_count },
 | 
| 
bsw@95
 | 
    98                       { color = "#eee", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count - record.minus2_fulfilled_count - record.minus1_fulfilled_count - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count - record.plus1_fulfilled_count - record.plus2_fulfilled_count},
 | 
| 
bsw/jbe@4
 | 
    99                       { color = "#f88", value = record.minus1_unfulfilled_count + record.minus1_fulfilled_count },
 | 
| 
bsw/jbe@4
 | 
   100                       { color = "#a00", value = record.minus2_unfulfilled_count + record.minus2_fulfilled_count },
 | 
| 
bsw/jbe@4
 | 
   101                     }
 | 
| 
bsw/jbe@4
 | 
   102                   }
 | 
| 
bsw/jbe@4
 | 
   103                 end
 | 
| 
bsw/jbe@4
 | 
   104               end
 | 
| 
bsw/jbe@4
 | 
   105             },
 | 
| 
bsw/jbe@4
 | 
   106             {
 | 
| 
bsw/jbe@4
 | 
   107               label = _"My opinion",
 | 
| 
bsw@95
 | 
   108               label_attr = { style = "width: 130px; font-style: italic;" },
 | 
| 
bsw/jbe@4
 | 
   109               content = function(record)
 | 
| 
bsw/jbe@4
 | 
   110                 local degree
 | 
| 
bsw@51
 | 
   111                 local opinion
 | 
| 
bsw@51
 | 
   112                 if app.session.member_id then
 | 
| 
bsw@51
 | 
   113                   opinion = Opinion:by_pk(app.session.member.id, record.id)
 | 
| 
bsw@51
 | 
   114                 end
 | 
| 
bsw/jbe@4
 | 
   115                 if opinion then
 | 
| 
bsw/jbe@4
 | 
   116                   degree = opinion.degree
 | 
| 
bsw@3
 | 
   117                 end
 | 
| 
bsw/jbe@5
 | 
   118                 ui.container{
 | 
| 
bsw/jbe@5
 | 
   119                   attr = { class = "suggestion_my_opinion" },
 | 
| 
bsw/jbe@5
 | 
   120                   content = function()
 | 
| 
bsw@51
 | 
   121                     if app.session.member_id then
 | 
| 
bsw@51
 | 
   122                       if initiative.issue.state == "voting" or initiative.issue.state == "closed" then
 | 
| 
bsw@95
 | 
   123                         if degree == -2 then
 | 
| 
bsw@95
 | 
   124                           ui.tag{
 | 
| 
bsw@95
 | 
   125                             tag = "span",
 | 
| 
bsw@95
 | 
   126                             attr = {
 | 
| 
bsw@95
 | 
   127                               class = "action" .. (degree == -2 and " active_red2" or "")
 | 
| 
bsw@95
 | 
   128                             },
 | 
| 
bsw@95
 | 
   129                             content = _"must not"
 | 
| 
bsw@95
 | 
   130                           }
 | 
| 
bsw@95
 | 
   131                         end
 | 
| 
bsw@95
 | 
   132                         if degree == -1 then
 | 
| 
bsw@95
 | 
   133                           ui.tag{
 | 
| 
bsw@95
 | 
   134                             tag = "span",
 | 
| 
bsw@95
 | 
   135                             attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
 | 
| 
bsw@95
 | 
   136                             content = _"should not"
 | 
| 
bsw@95
 | 
   137                           }
 | 
| 
bsw@95
 | 
   138                         end
 | 
| 
bsw@95
 | 
   139                         if degree == nil then
 | 
| 
bsw@95
 | 
   140                           ui.tag{
 | 
| 
bsw@95
 | 
   141                             tag = "span",
 | 
| 
bsw@95
 | 
   142                             attr = { class = "action" .. (degree == nil and " active" or "") },
 | 
| 
bsw@95
 | 
   143                             content = _"neutral"
 | 
| 
bsw@95
 | 
   144                           }
 | 
| 
bsw@95
 | 
   145                         end
 | 
| 
bsw@95
 | 
   146                         if degree == 1 then
 | 
| 
bsw@95
 | 
   147                           ui.tag{
 | 
| 
bsw@95
 | 
   148                             tag = "span",
 | 
| 
bsw@95
 | 
   149                             attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
 | 
| 
bsw@95
 | 
   150                             content = _"should"
 | 
| 
bsw@95
 | 
   151                           }
 | 
| 
bsw@95
 | 
   152                         end
 | 
| 
bsw@95
 | 
   153                         if degree == 2 then
 | 
| 
bsw@95
 | 
   154                           ui.tag{
 | 
| 
bsw@95
 | 
   155                             tag = "span",
 | 
| 
bsw@95
 | 
   156                             attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
 | 
| 
bsw@95
 | 
   157                             content = _"must"
 | 
| 
bsw@95
 | 
   158                           }
 | 
| 
bsw@95
 | 
   159                         end
 | 
| 
bsw@51
 | 
   160                       else
 | 
| 
poelzi@142
 | 
   161                         -- we need to put initiative_id into the parameters to have a redirect target in case the suggestion is gone after the action
 | 
| 
poelzi@142
 | 
   162                         params = param.get_all_cgi()
 | 
| 
poelzi@142
 | 
   163                         params['initiative_id'] = initiative.id
 | 
| 
poelzi@142
 | 
   164 
 | 
| 
bsw@51
 | 
   165                         ui.link{
 | 
| 
bsw@95
 | 
   166                           attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
 | 
| 
bsw@95
 | 
   167                           text = _"must",
 | 
| 
bsw@51
 | 
   168                           module = "opinion",
 | 
| 
bsw@51
 | 
   169                           action = "update",
 | 
| 
poelzi@142
 | 
   170                           routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } },
 | 
| 
bsw@51
 | 
   171                           params = {
 | 
| 
bsw@51
 | 
   172                             suggestion_id = record.id,
 | 
| 
bsw@95
 | 
   173                             degree = 2
 | 
| 
bsw@51
 | 
   174                           },
 | 
| 
bsw@51
 | 
   175                           partial = partial
 | 
| 
bsw@51
 | 
   176                         }
 | 
| 
bsw@51
 | 
   177                         slot.put(" ")
 | 
| 
bsw@51
 | 
   178                         ui.link{
 | 
| 
bsw@51
 | 
   179                           attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
 | 
| 
bsw@51
 | 
   180                           text = _"should",
 | 
| 
bsw@51
 | 
   181                           module = "opinion",
 | 
| 
bsw@51
 | 
   182                           action = "update",
 | 
| 
poelzi@142
 | 
   183                           routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params} },
 | 
| 
bsw@51
 | 
   184                           params = {
 | 
| 
bsw@51
 | 
   185                             suggestion_id = record.id,
 | 
| 
bsw@51
 | 
   186                             degree = 1
 | 
| 
bsw@51
 | 
   187                           },
 | 
| 
bsw@51
 | 
   188                           partial = partial
 | 
| 
bsw@51
 | 
   189                         }
 | 
| 
bsw@51
 | 
   190                         slot.put(" ")
 | 
| 
bsw@51
 | 
   191                         ui.link{
 | 
| 
bsw@95
 | 
   192                           attr = { class = "action" .. (degree == nil and " active" or "") },
 | 
| 
bsw@95
 | 
   193                           text = _"neutral",
 | 
| 
bsw@51
 | 
   194                           module = "opinion",
 | 
| 
bsw@51
 | 
   195                           action = "update",
 | 
| 
poelzi@142
 | 
   196                           routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } },
 | 
| 
bsw@51
 | 
   197                           params = {
 | 
| 
bsw@51
 | 
   198                             suggestion_id = record.id,
 | 
| 
bsw@95
 | 
   199                             delete = true
 | 
| 
bsw@95
 | 
   200                           },
 | 
| 
bsw@95
 | 
   201                           partial = partial
 | 
| 
bsw@95
 | 
   202                         }
 | 
| 
bsw@95
 | 
   203                         slot.put(" ")
 | 
| 
bsw@95
 | 
   204                         ui.link{
 | 
| 
bsw@95
 | 
   205                           attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
 | 
| 
bsw@95
 | 
   206                           text = _"should not",
 | 
| 
bsw@95
 | 
   207                           module = "opinion",
 | 
| 
bsw@95
 | 
   208                           action = "update",
 | 
| 
poelzi@142
 | 
   209                           routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } },
 | 
| 
bsw@95
 | 
   210                           params = {
 | 
| 
bsw@95
 | 
   211                             suggestion_id = record.id,
 | 
| 
bsw@95
 | 
   212                             degree = -1
 | 
| 
bsw@95
 | 
   213                           },
 | 
| 
bsw@95
 | 
   214                           partial = partial
 | 
| 
bsw@95
 | 
   215                         }
 | 
| 
bsw@95
 | 
   216                         slot.put(" ")
 | 
| 
bsw@95
 | 
   217                         ui.link{
 | 
| 
bsw@95
 | 
   218                           attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
 | 
| 
bsw@95
 | 
   219                           text = _"must not",
 | 
| 
bsw@95
 | 
   220                           module = "opinion",
 | 
| 
bsw@95
 | 
   221                           action = "update",
 | 
| 
poelzi@142
 | 
   222                           routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } },
 | 
| 
bsw@95
 | 
   223                           params = {
 | 
| 
bsw@95
 | 
   224                             suggestion_id = record.id,
 | 
| 
bsw@95
 | 
   225                             degree = -2
 | 
| 
bsw@51
 | 
   226                           },
 | 
| 
bsw@51
 | 
   227                           partial = partial
 | 
| 
bsw@51
 | 
   228                         }
 | 
| 
bsw@51
 | 
   229                       end
 | 
| 
bsw/jbe@19
 | 
   230                     else
 | 
| 
bsw@51
 | 
   231                       ui.field.text{ value = _"[Registered members only]" }
 | 
| 
bsw/jbe@19
 | 
   232                     end
 | 
| 
bsw/jbe@5
 | 
   233                   end
 | 
| 
bsw/jbe@0
 | 
   234                 }
 | 
| 
bsw/jbe@0
 | 
   235               end
 | 
| 
bsw/jbe@4
 | 
   236             },
 | 
| 
bsw/jbe@4
 | 
   237             {
 | 
| 
bsw/jbe@4
 | 
   238               label = _"Suggestion currently not implemented",
 | 
| 
bsw/jbe@4
 | 
   239               label_attr = { style = "width: 101px;" },
 | 
| 
bsw/jbe@4
 | 
   240               content = function(record)
 | 
| 
bsw/jbe@4
 | 
   241                 if record.minus2_unfulfilled_count then
 | 
| 
bsw@95
 | 
   242                   local max_value = record.initiative.supporter_count
 | 
| 
bsw/jbe@4
 | 
   243                   ui.bargraph{
 | 
| 
bsw/jbe@4
 | 
   244                     max_value = max_value,
 | 
| 
bsw@95
 | 
   245                     width = 100,
 | 
| 
bsw/jbe@4
 | 
   246                     bars = {
 | 
| 
bsw/jbe@4
 | 
   247                       { color = "#0a0", value = record.plus2_unfulfilled_count },
 | 
| 
bsw/jbe@4
 | 
   248                       { color = "#8f8", value = record.plus1_unfulfilled_count },
 | 
| 
bsw@95
 | 
   249                       { color = "#eee", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count },
 | 
| 
bsw@95
 | 
   250                       { color = "#f88", value = record.minus1_unfulfilled_count },
 | 
| 
bsw@95
 | 
   251                       { color = "#a00", value = record.minus2_unfulfilled_count },
 | 
| 
bsw/jbe@4
 | 
   252                     }
 | 
| 
bsw/jbe@4
 | 
   253                   }
 | 
| 
bsw/jbe@4
 | 
   254                 end
 | 
| 
bsw/jbe@4
 | 
   255               end
 | 
| 
bsw/jbe@4
 | 
   256             },
 | 
| 
bsw/jbe@4
 | 
   257             {
 | 
| 
bsw/jbe@4
 | 
   258               label = _"Suggestion currently implemented",
 | 
| 
bsw/jbe@4
 | 
   259               label_attr = { style = "width: 101px;" },
 | 
| 
bsw/jbe@4
 | 
   260               content = function(record)
 | 
| 
bsw/jbe@4
 | 
   261                 if record.minus2_fulfilled_count then
 | 
| 
bsw@95
 | 
   262                   local max_value = record.initiative.supporter_count
 | 
| 
bsw/jbe@4
 | 
   263                   ui.bargraph{
 | 
| 
bsw/jbe@4
 | 
   264                     max_value = max_value,
 | 
| 
bsw@95
 | 
   265                     width = 100,
 | 
| 
bsw/jbe@4
 | 
   266                     bars = {
 | 
| 
bsw@95
 | 
   267                       { color = "#0a0", value = record.plus2_fulfilled_count },
 | 
| 
bsw@95
 | 
   268                       { color = "#8f8", value = record.plus1_fulfilled_count },
 | 
| 
bsw@95
 | 
   269                       { color = "#eee", value = max_value - record.minus2_fulfilled_count - record.minus1_fulfilled_count - record.plus1_fulfilled_count - record.plus2_fulfilled_count},
 | 
| 
bsw/jbe@4
 | 
   270                       { color = "#f88", value = record.minus1_fulfilled_count },
 | 
| 
bsw/jbe@4
 | 
   271                       { color = "#a00", value = record.minus2_fulfilled_count },
 | 
| 
bsw/jbe@4
 | 
   272                     }
 | 
| 
bsw/jbe@4
 | 
   273                   }
 | 
| 
bsw/jbe@4
 | 
   274                 end
 | 
| 
bsw@3
 | 
   275               end
 | 
| 
bsw/jbe@4
 | 
   276             },
 | 
| 
bsw/jbe@4
 | 
   277             {
 | 
| 
bsw@95
 | 
   278               label = app.session.member_id and _"I consider suggestion as" or nil,
 | 
| 
bsw@95
 | 
   279               label_attr = { style = "width: 100px; font-style: italic;" },
 | 
| 
bsw/jbe@4
 | 
   280               content = function(record)
 | 
| 
bsw/jbe@4
 | 
   281                 local degree
 | 
| 
bsw@51
 | 
   282                 local opinion
 | 
| 
bsw@51
 | 
   283                 if app.session.member_id then
 | 
| 
bsw@51
 | 
   284                   opinion = Opinion:by_pk(app.session.member.id, record.id)
 | 
| 
bsw@51
 | 
   285                 end
 | 
| 
bsw/jbe@4
 | 
   286                 if opinion then
 | 
| 
bsw/jbe@4
 | 
   287                   degree = opinion.degree
 | 
| 
bsw/jbe@4
 | 
   288                 end
 | 
| 
bsw/jbe@4
 | 
   289                 if opinion then
 | 
| 
bsw@95
 | 
   290 
 | 
| 
bsw@95
 | 
   291                   ui.link{
 | 
| 
bsw@95
 | 
   292                     attr = { class = opinion.fulfilled and "action active" or "action" },
 | 
| 
bsw@95
 | 
   293                     text = _"implemented",
 | 
| 
bsw@95
 | 
   294                     module = "opinion",
 | 
| 
bsw@95
 | 
   295                     action = "update",
 | 
| 
bsw@95
 | 
   296                     routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
 | 
| 
bsw@95
 | 
   297                     params = {
 | 
| 
bsw@95
 | 
   298                       suggestion_id = record.id,
 | 
| 
bsw@95
 | 
   299                       fulfilled = true
 | 
| 
bsw@95
 | 
   300                     },
 | 
| 
bsw@95
 | 
   301                     partial = partial
 | 
| 
bsw@95
 | 
   302                   }
 | 
| 
bsw@95
 | 
   303                   slot.put("<br />")
 | 
| 
bsw@95
 | 
   304                   ui.link{
 | 
| 
bsw@95
 | 
   305                     attr = { class = not opinion.fulfilled and "action active" or "action" },
 | 
| 
bsw@95
 | 
   306                     text = _"not implemented",
 | 
| 
bsw@95
 | 
   307                     module = "opinion",
 | 
| 
bsw@95
 | 
   308                     action = "update",
 | 
| 
bsw@95
 | 
   309                     routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
 | 
| 
bsw@95
 | 
   310                     params = {
 | 
| 
bsw@95
 | 
   311                       suggestion_id = record.id,
 | 
| 
bsw@95
 | 
   312                       fulfilled = false
 | 
| 
bsw@95
 | 
   313                     },
 | 
| 
bsw@95
 | 
   314                     partial = partial
 | 
| 
bsw@95
 | 
   315                   }
 | 
| 
bsw@95
 | 
   316 
 | 
| 
bsw/jbe@4
 | 
   317                 end
 | 
| 
bsw/jbe@4
 | 
   318               end
 | 
| 
bsw/jbe@4
 | 
   319             },
 | 
| 
bsw/jbe@4
 | 
   320             {
 | 
| 
bsw@95
 | 
   321               label = app.session.member_id and _"So I'm" or nil,
 | 
| 
bsw/jbe@4
 | 
   322               content = function(record)
 | 
| 
bsw@51
 | 
   323                 local opinion
 | 
| 
bsw@51
 | 
   324                 if app.session.member_id then
 | 
| 
bsw@51
 | 
   325                   opinion = Opinion:by_pk(app.session.member.id, record.id)
 | 
| 
bsw@51
 | 
   326                 end
 | 
| 
bsw/jbe@4
 | 
   327                 if opinion then
 | 
| 
bsw/jbe@4
 | 
   328                   if (opinion.fulfilled and opinion.degree > 0) or (not opinion.fulfilled and opinion.degree < 0) then
 | 
| 
bsw@95
 | 
   329                     local title = _"satisfied"
 | 
| 
bsw@95
 | 
   330                     ui.image{ attr = { alt = title, title = title }, static = "icons/emoticon_happy.png" }
 | 
| 
bsw@95
 | 
   331                   elseif opinion.degree == 1 or opinion.degree == -1 then
 | 
| 
bsw@95
 | 
   332                     local title = _"a bit unsatisfied"
 | 
| 
bsw@95
 | 
   333                     ui.image{ attr = { alt = title, title = title }, static = "icons/emoticon_unhappy.png" }
 | 
| 
bsw/jbe@4
 | 
   334                   else
 | 
| 
bsw@95
 | 
   335                     local title = _"more unsatisfied"
 | 
| 
bsw@95
 | 
   336                     ui.image{ attr = { alt = title, title = title }, static = "icons/emoticon_unhappy_red.png" }
 | 
| 
bsw/jbe@4
 | 
   337                   end
 | 
| 
bsw/jbe@4
 | 
   338                 end
 | 
| 
bsw/jbe@4
 | 
   339               end
 | 
| 
bsw/jbe@4
 | 
   340             },
 | 
| 
bsw/jbe@4
 | 
   341           }
 | 
| 
bsw/jbe@4
 | 
   342         }
 | 
| 
bsw/jbe@4
 | 
   343       end
 | 
| 
bsw/jbe@0
 | 
   344     }
 | 
| 
bsw/jbe@0
 | 
   345   end
 | 
| 
bsw/jbe@0
 | 
   346 }
 |