Added views for QOR admin

This commit is contained in:
Nedim
2023-09-07 13:04:34 +02:00
parent 40c6366608
commit f02e5e49cb
180 changed files with 18556 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
<div class="qor-field">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" {{if .InputId}}for="{{.InputId}}"{{end}}>
<span class="qor-field__label mdl-checkbox__label">{{meta_label .Meta}}</span>
<span class="qor-field__edit">
<input type="checkbox" {{if .InputId}}id="{{.InputId}}"{{end}} name="{{.InputName}}" class="mdl-checkbox__input" value="true" type="checkbox" {{if .Value}}checked{{end}} {{if (not (has_change_permission .Meta)) }} disabled{{end}}>
{{if has_change_permission .Meta}}<input type="hidden" name="{{.InputName}}" value="false">{{end}}
</span>
</label>
</div>

View File

@@ -0,0 +1,41 @@
{{$metaConfig := .Meta.Config}}
{{$current_values := (raw_value_of .ResourceValue .Meta)}}
<div class="qor-field collection-edit qor-fieldset-container" {{if $metaConfig.Max}}data-max-item="{{$metaConfig.Max}}" data-max-item-hint="Up to {{$metaConfig.Max}} {{meta_label .Meta}}"{{end}}>
<label class="qor-field__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__block">
{{$meta := .Meta}}
{{if $current_values}}
{{range $index, $value := $current_values }}
<fieldset class="qor-fieldset">
{{if has_delete_permission $meta}}
<button data-confirm="{{t "qor_admin.form.are_you_sure" "Are you sure?"}}" class="mdl-button qor-button--muted mdl-button--icon mdl-js-button qor-fieldset__delete" type="button">
<i class="material-icons md-18">delete</i>
</button>
{{end}}
{{render_nested_form $value (edit_sections $meta.Resource) $index}}
</fieldset>
{{end}}
{{end}}
{{if has_create_permission .Meta}}
<fieldset class="qor-fieldset qor-fieldset--new">
<button data-confirm="{{t "qor_admin.form.are_you_sure" "Are you sure?"}}" class="mdl-button qor-button--muted mdl-button--icon mdl-js-button qor-fieldset__delete" type="button">
<i class="material-icons md-18">delete</i>
</button>
{{if $current_values}}
{{render_nested_form $meta.Resource.NewStruct (new_sections $meta.Resource) (len $current_values)}}
{{else}}
{{render_nested_form $meta.Resource.NewStruct (new_sections $meta.Resource) 0}}
{{end}}
</fieldset>
<button class="mdl-button mdl-button--primary qor-fieldset__add" type="button">
{{t (printf "%v.attributes.add_%v" .BaseResource.ToParam (singular (meta_label .Meta))) (printf "Add %v" (singular (meta_label .Meta)))}}
</button>
{{end}}
</div>
</div>

View File

@@ -0,0 +1,21 @@
<div class="qor-field">
<div class="mdl-textfield mdl-textfield--full-width mdl-js-textfield">
<label class="qor-field__label mdl-textfield__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show">
{{.Value}}
</div>
<div class="qor-field__edit qor-field__datepicker" data-picker-type="date">
<input class="mdl-textfield__input qor-datepicker__input" placeholder="{{meta_placeholder .Meta .Context "YYYY-MM-DD"}}" type="text" id="{{.InputId}}" name="{{.InputName}}" value="{{.Value}}" {{if (not (has_change_permission .Meta)) }} disabled{{end}}>
<div>
<button data-toggle="qor.datepicker" class="mdl-button mdl-js-button mdl-button--icon qor-action__datepicker" type="button">
<i class="material-icons">date_range</i>
</button>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,27 @@
<div class="qor-field">
<div class="mdl-textfield mdl-textfield--full-width mdl-js-textfield">
<label class="qor-field__label mdl-textfield__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show">
{{.Value}}
</div>
<div class="qor-field__edit {{if .Meta.Config.ShowTime}}qor-field__datetimepicker{{else}}qor-field__datepicker{{end}}" data-picker-type="{{if .Meta.Config.ShowTime}}datetime{{else}}date{{end}}">
<input class="mdl-textfield__input {{if .Meta.Config.ShowTime}}qor-datetimepicker__input{{else}}qor-datepicker__input{{end}}" placeholder="{{if .Meta.Config.ShowTime}}{{meta_placeholder .Meta .Context " YYYY-MM-DD HH:MM "}}{{else}}{{meta_placeholder .Meta .Context " YYYY-MM-DD "}}{{end}}" type="text" id="{{.InputId}}" name="{{.InputName}}" value="{{.Value}}" {{if (not (has_change_permission .Meta)) }} disabled{{end}}>
<div>
<button data-toggle="qor.datepicker" class="mdl-button mdl-js-button mdl-button--icon qor-action__datepicker" type="button">
<i class="material-icons">date_range</i>
</button>
{{if .Meta.Config.ShowTime}}
<button data-toggle="qor.timepicker" class="mdl-button mdl-js-button mdl-button--icon qor-action__timepicker" type="button">
<i class="material-icons">access_time</i>
</button>
{{end}}
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,15 @@
<div class="qor-field">
<div class="mdl-textfield mdl-textfield--full-width mdl-js-textfield">
<label class="qor-field__label mdl-textfield__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show">
{{.Value}}
</div>
<div class="qor-field__edit">
<input class="mdl-textfield__input" type="number" step="any" id="{{.InputId}}" name="{{.InputName}}" value="{{.Value}}" {{if not (has_change_permission .Meta) }}disabled{{end}}>
</div>
</div>
</div>

View File

@@ -0,0 +1 @@
<input id="{{.InputId}}" name="{{.InputName}}" value="{{.Value}}" type="hidden">

View File

@@ -0,0 +1 @@
<input id="{{.InputId}}" class="qor-hidden__primary_key" name="{{.InputName}}" value="{{.Value}}" type="hidden">

View File

@@ -0,0 +1,15 @@
<div class="qor-field">
<div class="mdl-textfield mdl-textfield--full-width mdl-js-textfield">
<label class="qor-field__label mdl-textfield__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show">
{{.Value}}
</div>
<div class="qor-field__edit">
<input class="mdl-textfield__input" type="number" id="{{.InputId}}" name="{{.InputName}}" value="{{.Value}}" {{if (not (has_change_permission .Meta)) }}disabled{{end}}>
</div>
</div>
</div>

View File

@@ -0,0 +1,16 @@
<div class="qor-field">
<div class="mdl-textfield mdl-textfield--full-width mdl-js-textfield">
<label class="qor-field__label mdl-textfield__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show">
******
</div>
<div class="qor-field__edit">
<input class="mdl-textfield__input" type="password" id="{{.InputId}}" placeholder="******" name="{{.InputName}}" value=""
{{if not (has_change_permission .Meta)}}disabled{{end}}>
</div>
</div>
</div>

View File

@@ -0,0 +1,15 @@
<div class="qor-field">
<div class="mdl-textfield mdl-textfield--full-width mdl-js-textfield">
<label class="qor-field__label mdl-textfield__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show">
{{.Value}}
</div>
<div class="qor-field__edit">
{{.Value}}
</div>
</div>
</div>

View File

@@ -0,0 +1,29 @@
<div class="qor-field">
<label class="qor-field__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show qor-redactor__show redactor-styles">{{raw .Value}}</div>
{{if .Meta.Config.Plugins}}
{{range $plugin := .Meta.Config.Plugins}}
<script src="{{$plugin.Source}}"></script>
{{end}}
{{end}}
{{$asset_manager := .Meta.Config.AssetManager}}
<div class="qor-field__edit qor-field__block qor-redactor-box">
<textarea class="qor-field__input" id="{{.InputId}}" name="{{.InputName}}" rows="10"
data-redactor-settings="{{marshal .Meta.Config.Settings}}"
data-toggle="qor.redactor"
{{if $asset_manager}}
{{$asset_router := printf "%v/%v" $asset_manager.GetAdmin.GetRouter.Prefix $asset_manager.ToParam}}
data-upload-url="{{$asset_router}}/upload"
data-crop-url="{{$asset_router}}/crop"
data-text="{&quot;title&quot;: &quot;{{t "qor_admin.form.crop_image" "Crop image"}}&quot;, &quot;ok&quot;: &quot;{{t "qor_admin.form.ok" "OK"}}&quot;, &quot;cancel&quot;: &quot;{{t "qor_admin.form.cancel" "Cancel"}}&quot;}"
{{end}}
{{if not (has_change_permission .Meta) }}disabled{{end}}>
{{.Value}}
</textarea>
</div>
</div>

View File

@@ -0,0 +1,95 @@
<div class="qor-field">
<label class="qor-field__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
{{$current_values := (raw_value_of .ResourceValue .Meta)}}
<div class="qor-field__show qor-field__selectmany-show">
{{range $value := .Value}}
<span>{{stringify $value}}</span>
{{end}}
</div>
{{if .Meta.Config.Select2ResultTemplate}}
<script name="select2-result-template" type="x-tmpl-mustache">
{{.Meta.Config.Select2ResultTemplate}}
</script>
{{end}}
{{if .Meta.Config.Select2SelectionTemplate}}
<script name="select2-selection-template" type="x-tmpl-mustache">
{{.Meta.Config.Select2SelectionTemplate}}
</script>
{{end}}
{{if (eq .Meta.Config.SelectMode "bottom_sheet")}}
<script name="select-many-selected-icon" type="x-tmpl-mustache">
<span class="qor-select__select-icon"><i class="material-icons">check_circle</i></span>
</script>
<script name="select-many-unselected-icon" type="x-tmpl-mustache">
<span class="qor-select__select-icon"><i class="material-icons">panorama_fish_eye</i></span>
</script>
<script name="select-many-hint" type="x-tmpl-mustache">
<div class="qor-selectmany__hint clearfix">
<span class="qor-selectmany__selectall">{{marshal (t "qor_admin.form.select_many_selectall" "select all")}}</span>
<span>[[ selectedNum ]] {{marshal (t "qor_admin.form.select_many_hint" "item(s) selected")}}</span>
<a href="#" data-dismiss="bottomsheets">{{t "qor_admin.form.select_many_hint_button" "DONE"}}</a>
</div>
</script>
<script name="select-many-template" type="x-tmpl-mustache">
<li data-primary-key="[[ primaryKey ]]">
<span>[[ &displayName ]]</span>
<a href="javascripr://" class="qor-selected-many__undo">
{{marshal (t "qor_admin.form.undo" "UNDO")}}
</a>
<a href="#" class="qor-selected-many__remove"><i class="material-icons">clear</i></a>
</li>
</script>
{{end}}
<div class="qor-field__edit qor-field__block qor-field__selectmany" {{if (eq .Meta.Config.SelectMode "bottom_sheet")}}data-toggle="qor.selectmany"{{end}} {{if (not (has_change_permission .Meta)) }}data-disabled="disabled"{{end}}>
{{if (eq .Meta.Config.SelectMode "bottom_sheet")}}
<ul class="qor-field__selected-many">
{{range $value := $current_values}}
<li data-primary-key="{{primary_key_of $value}}">
<span>{{stringify $value}}</span>
<a href="javascripr://" class="qor-selected-many__undo">UNDO</a>
<a href="javascripr://" class="qor-selected-many__remove"><i class="material-icons">clear</i></a>
</li>
{{end}}
</ul>
<a href="javascript://" class="mdl-button mdl-button--primary qor-field__selectmany-trigger" data-select-modal="many" {{if .InputId}}data-select-id="#{{.InputId}}"{{end}} data-select-listing-url="{{url_for .Meta.Config.RemoteDataResource}}" data-select-creating-url="{{new_resource_path .Meta.Config.RemoteDataResource}}" data-select-default-creating="{{.Meta.Config.DefaultCreating}}" {{if .Meta.Config.PrimaryField}}data-remote-data-primary-key="{{.Meta.Config.PrimaryField}}"{{end}}>
{{t "qor_admin.form.add_items" "ADD ITEMS"}}
</a>
<select class="qor-field__input qor-field__selectmany-input hidden" id="{{.InputId}}" data-init-data="{{range $value := $current_values}}{{primary_key_of $value}},{{end}}" name="{{.InputName}}" multiple {{if (not (has_change_permission .Meta)) }}disabled{{end}}>
{{range $value := $current_values}}
<option value="{{primary_key_of $value}}" selected>{{stringify $value}}</option>
{{end}}
</select>
{{else}}
<select class="qor-field__input hidden" id="{{.InputId}}" {{if not (eq .Meta.Config.SelectMode "bottom_sheet")}} data-toggle="qor.chooser" {{end}} data-placeholder="{{meta_placeholder .Meta .Context "Select some Options"}}" name="{{.InputName}}" multiple {{if (not (has_change_permission .Meta)) }}disabled{{end}} {{if .Meta.Config.RemoteDataResource}}data-remote-data="true" data-remote-url="{{url_for .Meta.Config.RemoteDataResource}}" {{if .Meta.Config.PrimaryField}}data-remote-data-primary-key="{{.Meta.Config.PrimaryField}}"{{end}}{{end}}>
{{if .Meta.Config.RemoteDataResource}}
{{range $value := $current_values}}
<option value="{{primary_key_of $value}}" selected>{{stringify $value}}</option>
{{end}}
{{else}}
{{range $values := (.Meta.Config.GetCollection .ResourceValue .Context)}}
{{if (is_included $current_values (index $values 0))}}
<option value="{{index $values 0}}" selected>{{index $values 1}}</option>
{{else}}
<option value="{{index $values 0}}">{{index $values 1}}</option>
{{end}}
{{end}}
{{end}}
</select>
{{end}}
{{if has_change_permission .Meta}}<input type="hidden" name="{{.InputName}}" value="">{{end}}
</div>
</div>

View File

@@ -0,0 +1,76 @@
{{$current_value := (raw_value_of .ResourceValue .Meta)}}
{{$is_existing_record := (not (is_new_record $current_value))}}
<div class="qor-field">
<label class="qor-field__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show">{{.Value}}</div>
{{if .Meta.Config.Select2ResultTemplate}}
<script name="select2-result-template" type="x-tmpl-mustache">
{{.Meta.Config.Select2ResultTemplate}}
</script>
{{end}}
{{if .Meta.Config.Select2SelectionTemplate}}
<script name="select2-selection-template" type="x-tmpl-mustache">
{{.Meta.Config.Select2SelectionTemplate}}
</script>
{{end}}
{{if (eq .Meta.Config.SelectMode "bottom_sheet")}}
<script name="select-one-selected-template" type="x-tmpl-mustache">
<p class="qor-field__selected" data-primary-key="[[ primaryKey ]]">
<span class="qor-selected__change">[[ &displayName ]]</span>
<a href="#" class="qor-selected__remove"><i class="material-icons">remove_circle_outline</i></a>
</p>
</script>
<script name="select-one-selected-icon" type="x-tmpl-mustache">
<span class="qor-select__select-icon"><i class="material-icons">check_circle</i></span>
</script>
{{end}}
<div class="qor-field__block qor-field__edit qor-field__selectone" {{if (eq .Meta.Config.SelectMode "bottom_sheet")}} data-toggle="qor.selectone"{{end}}>
{{if (eq .Meta.Config.SelectMode "bottom_sheet")}}
{{if $is_existing_record}}
<p class="qor-field__selected" data-primary-key="{{primary_key_of $current_value}}">
<span class="qor-selected__change">{{.Value}}</span>
<a href="javascripr://" class="qor-selected__remove"><i class="material-icons">remove_circle_outline</i></a>
</p>
{{end}}
<a href="javascript://" {{if $is_existing_record}}style="display:none"{{end}} class="mdl-button mdl-button--colored qor-field__selectone-trigger" data-select-modal="one" {{if .InputId}}data-select-id="#{{.InputId}}"{{end}} data-selectone-url="{{url_for .Meta.Config.RemoteDataResource}}" data-select-listing-url="{{url_for .Meta.Config.RemoteDataResource}}" data-select-creating-url="{{new_resource_path .Meta.Config.RemoteDataResource}}" data-select-default-creating="{{.Meta.Config.DefaultCreating}}" {{if .Meta.Config.PrimaryField}}data-remote-data-primary-key="{{.Meta.Config.PrimaryField}}"{{end}}>{{meta_placeholder .Meta .Context "Click to Select"}}</a>
<select id="{{.InputId}}" class="qor-field__input qor-field__selectone-input hidden" name="{{.InputName}}" {{if (not (has_change_permission .Meta)) }}disabled{{end}}>
{{if $is_existing_record}}
<option value="{{primary_key_of $current_value}}" selected>{{.Value}}</option>
{{end}}
</select>
{{else}}
<select id="{{.InputId}}" class="qor-field__input hidden" {{if .Meta.Config.RemoteDataResource}}{{if $is_existing_record}}chooser-selected="true"{{end}}{{end}} data-toggle="qor.chooser" data-placeholder="{{meta_placeholder .Meta .Context "Select an Option"}}" name="{{.InputName}}" {{if (not (has_change_permission .Meta)) }}disabled{{end}} {{if .Meta.Config.AllowBlank}}data-allow-clear="true"{{end}} {{if .Meta.Config.RemoteDataResource}}data-remote-url="{{url_for .Meta.Config.RemoteDataResource}}" data-remote-data="true" {{if .Meta.Config.RemoteDataHasImage}}data-remote-image="true"{{end}} {{if .Meta.Config.PrimaryField}}data-remote-data-primary-key="{{.Meta.Config.PrimaryField}}"{{end}}{{end}}>
{{if .Meta.Config.RemoteDataResource}}
{{if $is_existing_record}}
<option value="{{primary_key_of $current_value}}" selected>{{.Value}}</option>
{{end}}
{{else}}
{{if .Meta.Config.AllowBlank}}
<option></option>
{{end}}
{{range $values := (.Meta.Config.GetCollection .ResourceValue .Context)}}
{{if (is_equal $current_value (index $values 0))}}
<option value="{{index $values 0}}" selected>{{index $values 1}}</option>
{{else}}
<option value="{{index $values 0}}">{{index $values 1}}</option>
{{end}}
{{end}}
{{end}}
</select>
{{end}}
{{if has_change_permission .Meta}}<input type="hidden" name="{{.InputName}}" value="">{{end}}
</div>
</div>

View File

@@ -0,0 +1,14 @@
{{$value := (raw_value_of .ResourceValue .Meta)}}
{{if (or (not (is_new_record $value)) (has_create_permission .Meta))}}
<div class="signle-edit qor-field">
<label class="qor-field__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__block">
<fieldset id="{{.InputId}}" class="qor-fieldset">
{{render_nested_form $value (edit_sections .Meta.Resource) -1}}
</fieldset>
</div>
</div>
{{end}}

View File

@@ -0,0 +1,13 @@
<div class="qor-field">
<div class="mdl-textfield mdl-textfield--full-width mdl-js-textfield">
<label class="qor-field__label mdl-textfield__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show">{{.Value}}</div>
<div class="qor-field__edit">
<input class="mdl-textfield__input" type="text" id="{{.InputId}}" name="{{.InputName}}" value="{{.Value}}" {{if (not (has_change_permission .Meta)) }}disabled{{end}}>
</div>
</div>
</div>

View File

@@ -0,0 +1,13 @@
<div class="qor-field">
<div class="mdl-textfield mdl-textfield--full-width mdl-js-textfield">
<label class="qor-field__label" for="{{.InputId}}">
{{meta_label .Meta}}
</label>
<div class="qor-field__show">{{.Value}}</div>
<div class="qor-field__edit">
<textarea class="mdl-textfield__input qor-js-autoheight" id="{{.InputId}}" name="{{.InputName}}" rows="1" {{if (not (has_change_permission .Meta)) }}disabled{{end}}>{{.Value}}</textarea>
</div>
</div>
</div>