Skip to content

Commit

Permalink
Hide actions sections when it is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
raven-chen committed Aug 11, 2020
1 parent 5dfff87 commit 3a49353
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions views/metas/form/group_permission.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,35 @@
</label>
</div>

<label class="qor-field__label" for="">
Actions
</label>
{{if gt (len $value.Actions) 0 }}
<label class="qor-field__label" for="">
Actions
</label>

{{ $flag := 0 }}
{{range $i, $actionValue := $value.Actions }}
{{ if eq (mod $i 2) 0 }}
<div class="qor-form-section-rows qor-section-columns-2 clearfix">
{{ else }}
{{ $flag = 1 }}
{{ end }}
<div class="qor-field">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" id="Resource-{{$index}}-Action-{{$i}}-{{$value.Name}}">
<span class="qor-field__label mdl-checkbox__label">{{$actionValue.Name}}</span>
{{ $flag := 0 }}
{{range $i, $actionValue := $value.Actions }}
{{ if eq (mod $i 2) 0 }}
<div class="qor-form-section-rows qor-section-columns-2 clearfix">
{{ else }}
{{ $flag = 1 }}
{{ end }}
<div class="qor-field">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" id="Resource-{{$index}}-Action-{{$i}}-{{$value.Name}}">
<span class="qor-field__label mdl-checkbox__label">{{$actionValue.Name}}</span>

<span class="qor-field__edit">
<input type="checkbox" id="Resource-{{$index}}-Action-{{$i}}-{{$value.Name}}" name="QorResource.ResourcePermissions[{{$index}}].Actions[{{$i}}].Allowed" class="mdl-checkbox__input" value="true" type="checkbox" {{if $actionValue.Allowed}}checked{{end}}>
<input type="hidden" name="QorResource.ResourcePermissions[{{$index}}].Actions[{{$i}}].Allowed" value="false">
<input type="hidden" name="QorResource.ResourcePermissions[{{$index}}].Actions[{{$i}}].Name" value={{$actionValue.Name}}>
</span>
</label>
<span class="qor-field__edit">
<input type="checkbox" id="Resource-{{$index}}-Action-{{$i}}-{{$value.Name}}" name="QorResource.ResourcePermissions[{{$index}}].Actions[{{$i}}].Allowed" class="mdl-checkbox__input" value="true" type="checkbox" {{if $actionValue.Allowed}}checked{{end}}>
<input type="hidden" name="QorResource.ResourcePermissions[{{$index}}].Actions[{{$i}}].Allowed" value="false">
<input type="hidden" name="QorResource.ResourcePermissions[{{$index}}].Actions[{{$i}}].Name" value={{$actionValue.Name}}>
</span>
</label>
</div>
{{ if eq $flag 1 }}
</div>
{{ if eq $flag 1 }}
</div>
{{ $flag = 0 }}
{{ $flag = 0 }}
{{ end }}
{{end}}
{{ end }}
{{end}}
</fieldset>
{{end}}
{{end}}
Expand Down

0 comments on commit 3a49353

Please sign in to comment.