annotate env/ui/supporter_count.lua @ 1854:220653575083
Show token weight correctly
 | author | 
 bsw | 
 | date | 
 Tue Mar 22 13:55:02 2022 +0100 (2022-03-22) | 
 | parents | 
 accb808d5b4a  | 
 | children | 
  | 
 
 | rev | 
   line source | 
| 
bsw/jbe@1309
 | 
     1 function ui.supporter_count(initiative)
 | 
| 
bsw/jbe@1309
 | 
     2   if initiative.supporter_count == nil then
 | 
| 
bsw/jbe@1309
 | 
     3     ui.tag { 
 | 
| 
bsw/jbe@1309
 | 
     4       attr = { class = "supporterCount" },
 | 
| 
bsw/jbe@1309
 | 
     5       content = _"[calculating]"
 | 
| 
bsw/jbe@1309
 | 
     6     }
 | 
| 
bsw/jbe@1309
 | 
     7   elseif initiative.issue.closed == nil then
 | 
| 
bsw@1850
 | 
     8     if config.token and initiative.issue.area.unit_id == config.token.unit_id then
 | 
| 
bsw/jbe@1309
 | 
     9       ui.tag { 
 | 
| 
bsw@1850
 | 
    10         attr = { class = "satisfiedSupporterCount" },
 | 
| 
bsw@1850
 | 
    11         content = _("#{count} #{token_name}", { count = initiative.satisfied_supporter_count / 100, token_name = config.token.token_name })
 | 
| 
bsw/jbe@1309
 | 
    12       }
 | 
| 
bsw@1850
 | 
    13       if initiative.potential_supporter_count and
 | 
| 
bsw@1850
 | 
    14           initiative.potential_supporter_count > 0 
 | 
| 
bsw@1850
 | 
    15       then
 | 
| 
bsw@1850
 | 
    16         slot.put ( " " )
 | 
| 
bsw@1850
 | 
    17         ui.tag { 
 | 
| 
bsw@1850
 | 
    18           attr = { class = "potentialSupporterCount" },
 | 
| 
bsw@1850
 | 
    19           content = _("(+ #{count} potential)", { count = initiative.potential_supporter_count / 100 })
 | 
| 
bsw@1850
 | 
    20         }
 | 
| 
bsw@1850
 | 
    21       end
 | 
| 
bsw@1850
 | 
    22     else
 | 
| 
bsw@1850
 | 
    23       ui.tag { 
 | 
| 
bsw@1850
 | 
    24         attr = { class = "satisfiedSupporterCount" },
 | 
| 
bsw@1850
 | 
    25         content = _("#{count} supporter", { count = initiative.satisfied_supporter_count })
 | 
| 
bsw@1850
 | 
    26       }
 | 
| 
bsw@1850
 | 
    27       if initiative.potential_supporter_count and
 | 
| 
bsw@1850
 | 
    28           initiative.potential_supporter_count > 0 
 | 
| 
bsw@1850
 | 
    29       then
 | 
| 
bsw@1850
 | 
    30         slot.put ( " " )
 | 
| 
bsw@1850
 | 
    31         ui.tag { 
 | 
| 
bsw@1850
 | 
    32           attr = { class = "potentialSupporterCount" },
 | 
| 
bsw@1850
 | 
    33           content = _("(+ #{count} potential)", { count = initiative.potential_supporter_count })
 | 
| 
bsw@1850
 | 
    34         }
 | 
| 
bsw@1850
 | 
    35       end
 | 
| 
bsw/jbe@1309
 | 
    36     end
 | 
| 
bsw/jbe@1309
 | 
    37   end 
 | 
| 
bsw/jbe@1309
 | 
    38 end
 |