liquid_feedback_frontend

diff app/main/initiative/new.lua @ 1309:32cc544d5a5b

Cumulative patch for upcoming frontend version 4
author bsw/jbe
date Sun Jul 15 14:07:29 2018 +0200 (2018-07-15)
parents 9fed7af9263f
children
line diff
     1.1 --- a/app/main/initiative/new.lua	Thu Jun 23 03:30:57 2016 +0200
     1.2 +++ b/app/main/initiative/new.lua	Sun Jul 15 14:07:29 2018 +0200
     1.3 @@ -33,29 +33,21 @@
     1.4      module = "issue", view = "_head", 
     1.5      params = { issue = issue, member = app.session.member }
     1.6    }
     1.7 -  execute.view { 
     1.8 -    module = "issue", view = "_sidebar_state", 
     1.9 -    params = {
    1.10 -      issue = issue
    1.11 -    }
    1.12 -  }
    1.13 -  execute.view { 
    1.14 -    module = "issue", view = "_sidebar_issue", 
    1.15 -    params = {
    1.16 -      issue = issue
    1.17 -    }
    1.18 -  }
    1.19  else
    1.20 +  --[[
    1.21    execute.view {
    1.22      module = "area", view = "_head", 
    1.23      params = { area = area, member = app.session.member }
    1.24    }
    1.25 +  --]]
    1.26 +  --[[
    1.27    execute.view { 
    1.28      module = "initiative", view = "_sidebar_policies", 
    1.29      params = {
    1.30        area = area,
    1.31      }
    1.32    }
    1.33 +  --]]
    1.34  end
    1.35  
    1.36  ui.form{
    1.37 @@ -67,216 +59,221 @@
    1.38    },
    1.39    attr = { class = "vertical" },
    1.40    content = function()
    1.41 -  
    1.42 -    if preview then
    1.43 -      ui.section( function()
    1.44 -        ui.sectionHead( function()
    1.45 -          ui.heading{ level = 1, content = encode.html(param.get("name")) }
    1.46 -          if not issue then
    1.47 -            ui.container { content = policy.name }
    1.48 -          end
    1.49 -	  if param.get("free_timing") then
    1.50 -	    ui.container { content = param.get("free_timing") }
    1.51 -	  end
    1.52 -          slot.put("<br />")
    1.53 -
    1.54 -          ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
    1.55 -          ui.field.hidden{ name = "policy_id", value = param.get("policy_id") }
    1.56 -          ui.field.hidden{ name = "name", value = param.get("name") }
    1.57 -          ui.field.hidden{ name = "draft", value = param.get("draft") }
    1.58 -          ui.field.hidden{ name = "free_timing", value = param.get("free_timing") }
    1.59 -          ui.field.hidden{ name = "polling", value = param.get("polling", atom.boolean) }
    1.60 -          local formatting_engine
    1.61 -          if config.enforce_formatting_engine then
    1.62 -            formatting_engine = config.enforce_formatting_engine
    1.63 -          else
    1.64 -            formatting_engine = param.get("formatting_engine")
    1.65 -          end
    1.66 -          ui.container{
    1.67 -            attr = { class = "draft" },
    1.68 -            content = function()
    1.69 -              slot.put(format.wiki_text(param.get("draft"), formatting_engine))
    1.70 -            end
    1.71 -          }
    1.72 -          slot.put("<br />")
    1.73 -
    1.74 -          ui.tag{
    1.75 -            tag = "input",
    1.76 -            attr = {
    1.77 -              type = "submit",
    1.78 -              class = "btn btn-default",
    1.79 -              value = _'Publish now'
    1.80 -            },
    1.81 -            content = ""
    1.82 -          }
    1.83 -          slot.put("<br />")
    1.84 -          slot.put("<br />")
    1.85 -          ui.tag{
    1.86 -            tag = "input",
    1.87 -            attr = {
    1.88 -              type = "submit",
    1.89 -              name = "edit",
    1.90 -              class = "btn-link",
    1.91 -              value = _'Edit again'
    1.92 -            },
    1.93 -            content = ""
    1.94 -          }
    1.95 -          slot.put(" | ")
    1.96 -          if issue then
    1.97 -            ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
    1.98 -          else
    1.99 -            ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
   1.100 -          end
   1.101 -        end )
   1.102 -      end )
   1.103 -    else
   1.104 -      
   1.105 -     
   1.106 -      execute.view{ module = "initiative", view = "_sidebar_wikisyntax" }
   1.107 -
   1.108 -      ui.section( function()
   1.109 -        if preview then
   1.110 -          ui.sectionHead( function()
   1.111 -            ui.heading { level = 1, content = _"Edit again" }
   1.112 -          end )
   1.113 -        elseif issue_id then
   1.114 -          ui.sectionHead( function()
   1.115 -            ui.heading { level = 1, content = _"Add a new competing initiative to issue" }
   1.116 -          end )
   1.117 -        else
   1.118 -          ui.sectionHead( function()
   1.119 -            ui.heading { level = 1, content = _"Create a new issue" }
   1.120 -          end )
   1.121 -        end
   1.122 -      
   1.123 -        ui.sectionRow( function()
   1.124 -          if not preview and not issue_id then
   1.125 -            ui.container { attr = { class = "section" }, content = _"Before creating a new issue, please check any existant issues before, if the topic is already in discussion." }
   1.126 -            slot.put("<br />")
   1.127 -          end
   1.128 -          if not issue_id then
   1.129 -            local tmp = { { id = -1, name = "" } }
   1.130 -            for i, allowed_policy in ipairs(area.allowed_policies) do
   1.131 -              if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
   1.132 -                tmp[#tmp+1] = allowed_policy
   1.133 -              end
   1.134 +    ui.grid{ content = function()
   1.135 +      ui.cell_main{ content = function()
   1.136 +        ui.container{ attr = { class = "mdl-card mdl-shadow--2dp mdl-card__fullwidth" }, content = function()
   1.137 +          ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
   1.138 +            if preview then
   1.139 +              ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Preview" }
   1.140 +            elseif issue_id then
   1.141 +              ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"New competing initiative" }
   1.142 +            else
   1.143 +              ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Create a new issue" }
   1.144              end
   1.145 -            ui.heading{ level = 2, content = _"Please choose a policy for the new issue:" }
   1.146 -            ui.field.select{
   1.147 -              name = "policy_id",
   1.148 -              foreign_records = tmp,
   1.149 -              foreign_id = "id",
   1.150 -              foreign_name = "name",
   1.151 -              value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
   1.152 -            }
   1.153 -            if policy and policy.free_timeable then
   1.154 -	      local available_timings
   1.155 -	      if config.free_timing and config.free_timing.available_func then
   1.156 -		available_timings = config.free_timing.available_func(policy)
   1.157 -		if available_timings == false then
   1.158 -		  error("error in free timing config")
   1.159 -		end
   1.160 -	      end
   1.161 -	      ui.heading{ level = 4, content = _"Free timing:" }
   1.162 -	      if available_timings then
   1.163 -		ui.field.select{
   1.164 -		  name = "free_timing",
   1.165 -		  foreign_records = available_timings,
   1.166 -		  foreign_id = "id",
   1.167 -		  foreign_name = "name",
   1.168 -		  value = param.get("free_timing")
   1.169 -		}
   1.170 -	      else
   1.171 -		ui.field.text{
   1.172 -		  name = "free_timing",
   1.173 -		  value = param.get("free_timing")
   1.174 -		}
   1.175 -	      end
   1.176 -            end
   1.177 -          end
   1.178 +          end }
   1.179 +            
   1.180 +          ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
   1.181  
   1.182 -          if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
   1.183 -            slot.put("<br />")
   1.184 -            ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling }
   1.185 -          end
   1.186 -          
   1.187 -          slot.put("<br />")
   1.188 -          ui.heading { level = 2, content = _"Enter a title for your initiative (max. 140 chars):" }
   1.189 -          ui.field.text{
   1.190 -            attr = { style = "width: 100%;" },
   1.191 -            name  = "name",
   1.192 -            value = param.get("name")
   1.193 -          }
   1.194 -          ui.container { content = _"The title is the figurehead of your iniative. It should be short but meaningful! As others identifies your initiative by this title, you cannot change it later!" }
   1.195            
   1.196 -          if not config.enforce_formatting_engine then
   1.197 -            slot.put("<br />")
   1.198 -            ui.heading { level = 4, content = _"Choose a formatting engine:" }
   1.199 -            ui.field.select{
   1.200 -              name = "formatting_engine",
   1.201 -              foreign_records = config.formatting_engines,
   1.202 -              attr = {id = "formatting_engine"},
   1.203 -              foreign_id = "id",
   1.204 -              foreign_name = "name",
   1.205 -              value = param.get("formatting_engine")
   1.206 -            }
   1.207 -          end
   1.208 -          slot.put("<br />")
   1.209 +            if preview then
   1.210 +              
   1.211 +              ui.section( function()
   1.212 +                ui.sectionHead( function()
   1.213 +                  ui.heading{ level = 1, content = encode.html(param.get("name")) }
   1.214 +                  if not issue then
   1.215 +                    ui.container { content = policy.name }
   1.216 +                  end
   1.217 +                  if param.get("free_timing") then
   1.218 +                    ui.container { content = param.get("free_timing") }
   1.219 +                  end
   1.220 +                  slot.put("<br />")
   1.221 +                  
   1.222 +                  local draft_text = param.get("draft")
   1.223 +                  local draft_text = util.wysihtml_preproc(draft_text)
   1.224  
   1.225 -          ui.heading { level = 2, content = _"Enter your proposal and/or reasons:" }
   1.226 -          ui.field.text{
   1.227 -            name = "draft",
   1.228 -            multiline = true, 
   1.229 -            attr = { style = "height: 50ex; width: 100%;" },
   1.230 -            value = param.get("draft") or config.draft_template or [[
   1.231 -Proposal
   1.232 -======
   1.233 -
   1.234 -Replace me with your proposal.
   1.235 -
   1.236 -
   1.237 -Reasons
   1.238 -======
   1.239 -
   1.240 -Argument 1
   1.241 -------
   1.242 -
   1.243 -Replace me with your first argument
   1.244 -
   1.245 +                  ui.field.hidden{ name = "policy_id", value = param.get("policy_id") }
   1.246 +                  ui.field.hidden{ name = "name", value = param.get("name") }
   1.247 +                  if config.initiative_abstract then
   1.248 +                    ui.field.hidden{ name = "abstract", value = param.get("abstract") }
   1.249 +                    ui.container{
   1.250 +                      attr = { class = "abstract" },
   1.251 +                      content = param.get("abstract")
   1.252 +                    }
   1.253 +                    slot.put("<br />")
   1.254 +                  end
   1.255 +                  ui.field.hidden{ name = "draft", value = draft_text }
   1.256 +                  ui.field.hidden{ name = "free_timing", value = param.get("free_timing") }
   1.257 +                  ui.field.hidden{ name = "polling", value = param.get("polling", atom.boolean) }
   1.258 +                  ui.field.hidden{ name = "location", value = param.get("location") }
   1.259 +                  local formatting_engine
   1.260 +                  if config.enforce_formatting_engine then
   1.261 +                    formatting_engine = config.enforce_formatting_engine
   1.262 +                  else
   1.263 +                    formatting_engine = param.get("formatting_engine")
   1.264 +                  end
   1.265 +                  ui.container{
   1.266 +                    attr = { class = "draft" },
   1.267 +                    content = function()
   1.268 +                      slot.put(draft_text)
   1.269 +                    end
   1.270 +                  }
   1.271 +                  slot.put("<br />")
   1.272  
   1.273 -Argument 2
   1.274 -------
   1.275 -
   1.276 -Replace me with your second argument
   1.277 +                  ui.tag{
   1.278 +                    tag = "input",
   1.279 +                    attr = {
   1.280 +                      type = "submit",
   1.281 +                      class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored",
   1.282 +                      value = _'Publish now'
   1.283 +                    },
   1.284 +                    content = ""
   1.285 +                  }
   1.286 +                  slot.put(" &nbsp; ")
   1.287 +                  ui.tag{
   1.288 +                    tag = "input",
   1.289 +                    attr = {
   1.290 +                      type = "submit",
   1.291 +                      name = "edit",
   1.292 +                      class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect",
   1.293 +                      value = _'Edit again'
   1.294 +                    },
   1.295 +                    content = ""
   1.296 +                  }
   1.297 +                  slot.put(" &nbsp; ")
   1.298 +                  local class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
   1.299 +                  if issue then
   1.300 +                    ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id, attr = { class = class } }
   1.301 +                  else
   1.302 +                    ui.link{ content = _"Cancel", module = "index", view = "index", params = { unit = area.unit_id, area = area.id }, attr = { class = class } }
   1.303 +                  end
   1.304 +                end )
   1.305 +              end )
   1.306 +            else
   1.307 +              
   1.308 +              ui.sectionRow( function()
   1.309 +              --[[
   1.310 +                if not preview and not issue_id then
   1.311 +                  ui.container { attr = { class = "section" }, content = _"Before creating a new issue, please check any existant issues before, if the topic is already in discussion." }
   1.312 +                  slot.put("<br />")
   1.313 +                end
   1.314 +              --]]
   1.315 +                if not issue_id then
   1.316 +                  local tmp = { { id = -1, name = "" } }
   1.317 +                  for i, allowed_policy in ipairs(area.allowed_policies) do
   1.318 +                    if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
   1.319 +                      tmp[#tmp+1] = allowed_policy
   1.320 +                    end
   1.321 +                  end
   1.322 +                  ui.container{ content = _"Please choose a policy for the new issue:" }
   1.323 +                  ui.field.select{
   1.324 +                    name = "policy_id",
   1.325 +                    foreign_records = tmp,
   1.326 +                    foreign_id = "id",
   1.327 +                    foreign_name = "name",
   1.328 +                    value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
   1.329 +                  }
   1.330 +                  if policy and policy.free_timeable then
   1.331 +                    local available_timings
   1.332 +                    if config.free_timing and config.free_timing.available_func then
   1.333 +                      available_timings = config.free_timing.available_func(policy)
   1.334 +                      if available_timings == false then
   1.335 +                        slot.put_into("error", "error in free timing config")
   1.336 +                        return false
   1.337 +                      end
   1.338 +                    end
   1.339 +                    ui.heading{ level = 4, content = _"Free timing:" }
   1.340 +                    if available_timings then
   1.341 +                      ui.field.select{
   1.342 +                        name = "free_timing",
   1.343 +                        foreign_records = available_timings,
   1.344 +                        foreign_id = "id",
   1.345 +                        foreign_name = "name",
   1.346 +                        value = param.get("free_timing")
   1.347 +                      }
   1.348 +                    else
   1.349 +                      ui.field.text{
   1.350 +                        name = "free_timing",
   1.351 +                        value = param.get("free_timing")
   1.352 +                      }
   1.353 +                    end
   1.354 +                  end
   1.355 +                end
   1.356  
   1.357 -]]
   1.358 -          }
   1.359 -          if not issue or issue.state == "admission" or issue.state == "discussion" then
   1.360 -            ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
   1.361 -          else
   1.362 -            ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
   1.363 -          end
   1.364 -          slot.put("<br />")
   1.365 -          ui.tag{
   1.366 -            tag = "input",
   1.367 -            attr = {
   1.368 -              type = "submit",
   1.369 -              name = "preview",
   1.370 -              class = "btn btn-default",
   1.371 -              value = _'Preview'
   1.372 -            },
   1.373 -            content = ""
   1.374 -          }
   1.375 -          slot.put("<br />")
   1.376 -          slot.put("<br />")
   1.377 -          
   1.378 -          if issue then
   1.379 -            ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
   1.380 -          else
   1.381 -            ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
   1.382 -          end
   1.383 -        end )
   1.384 -      end )
   1.385 -    end
   1.386 +                if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
   1.387 +                  slot.put("<br />")
   1.388 +                  ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling }
   1.389 +                end
   1.390 +                
   1.391 +                ui.container{ attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label mdl-card__fullwidth" }, content = function ()
   1.392 +                  ui.field.text{
   1.393 +                    attr = { id = "lf-initiative__name", class = "mdl-textfield__input" },
   1.394 +                    label_attr = { class = "mdl-textfield__label", ["for"] = "lf-initiative__name" },
   1.395 +                    label = _"Title",
   1.396 +                    name  = "name",
   1.397 +                    value = param.get("name")
   1.398 +                  }
   1.399 +                end }
   1.400 +                
   1.401 +                if config.initiative_abstract then
   1.402 +                  ui.container { content = _"Enter abstract:" }
   1.403 +                  ui.container{ attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--expandable mdl-textfield__fullwidth" }, content = function()
   1.404 +                    ui.field.text{
   1.405 +                      name = "abstract",
   1.406 +                      multiline = true, 
   1.407 +                      attr = { id = "abstract", style = "height: 20ex; width: 100%;" },
   1.408 +                      value = param.get("abstract")
   1.409 +                    }
   1.410 +                  end }
   1.411 +                end
   1.412 +                
   1.413 +                ui.container { content = _"Enter your proposal and/or reasons:" }
   1.414 +                ui.container{ attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--expandable mdl-textfield__fullwidth" }, content = function()
   1.415 +                  ui.field.wysihtml{
   1.416 +                    name = "draft",
   1.417 +                    multiline = true, 
   1.418 +                    attr = { id = "draft", style = "height: 50ex; width: 100%;" },
   1.419 +                    value = param.get("draft") or config.draft_template
   1.420 +                  }
   1.421 +                end }
   1.422 +                if not issue or issue.state == "admission" or issue.state == "discussion" then
   1.423 +                  ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
   1.424 +                else
   1.425 +                  ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
   1.426 +                end
   1.427 +                slot.put("<br />")
   1.428 +                                
   1.429 +                slot.put("<br />")
   1.430 +                ui.tag{
   1.431 +                  tag = "input",
   1.432 +                  attr = {
   1.433 +                    type = "submit",
   1.434 +                    name = "preview",
   1.435 +                    class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored",
   1.436 +                    value = _'Preview'
   1.437 +                  },
   1.438 +                  content = ""
   1.439 +                }
   1.440 +                slot.put(" &nbsp; ")
   1.441 +                
   1.442 +                local class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
   1.443 +                if issue then
   1.444 +                  
   1.445 +                  ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id, attr = { class = class } }
   1.446 +                else
   1.447 +                  ui.link{ content = _"Cancel", module = "index", view = "index", params = { unit = area.unit_id, area = area.id }, attr = { class = class } }
   1.448 +                end
   1.449 +              end )
   1.450 +            end
   1.451 +          end }
   1.452 +        end }
   1.453 +      end }
   1.454 +      if config.map or config.firstlife then
   1.455 +        ui.cell_sidebar{ content = function()
   1.456 +          ui.container{ attr = { class = "mdl-special-card map mdl-shadow--2dp" }, content = function()
   1.457 +            ui.field.location{ name = "location", value = param.get("location") }
   1.458 +          end }
   1.459 +        end }
   1.460 +      end
   1.461 +    end }
   1.462    end
   1.463  }

Impressum / About Us