Files
dw-sheet-data-checker/templates/editor/js-template-repeater-card.php
2025-11-16 01:01:53 +07:00

214 lines
12 KiB
PHP

<!-- Handlebars Template for Fields -->
<script id="fields-template" type="text/x-handlebars-template">
{{#each fields}}
<div class="dw-checker-field">
<label for="{{fieldId}}" style="color: {{fieldLabelColor}}; display: {{fieldDisplayLabel}};">{{fieldLabel}}</label>
{{#if isTextField}}
<input name="{{fieldId}}" placeholder="{{fieldPlaceholder}}"/>
{{else if isSelectField}}
<select name="{{fieldId}}" placeholder="{{fieldPlaceholder}}">
<option value="" selected disabled>-- {{fieldPlaceholder}} --</option>
{{#each uniqueValues}}
<option value="{{this}}">{{this}}</option>
{{/each}}
</select>
{{/if}}
</div>
{{/each}}
</script>
<!-- Vertical Table Template -->
<script id="vertical-table-template" type="text/x-handlebars-template">
<div class="dw-checker-results-container">
{{#each results}}
<div class="result-page" data-page="{{@index}}">
<table class="dw-checker-result-table" {{{getStyle ../resultDivider ../resultDividerWidth}}}>
<tbody>
{{#each this}}
{{#unless (getColumnSetting @key 'hide')}}
<tr>
<th {{{getStyleHeader ../resultDivider ../resultDividerWidth ../headerColor}}}>
<span class="dw-checker-result-header">{{@key}}</span>
</th>
<td {{{getStyleValue ../resultDivider ../resultDividerWidth ../valueColor}}}>
{{#if (eq (getColumnSetting @key 'type') 'link_button')}}
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} <a href="{{getValueWithPrefix @key}}" class="btn btn-primary">{{getColumnSetting @key 'button_text'}}</a></span>
{{else if (eq (getColumnSetting @key 'type') 'whatsapp_button')}}
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} <a href="https://wa.me/{{getValueWithPrefix @key}}" class="btn btn-success">{{getColumnSetting @key 'button_text'}}</a></span>
{{else if (eq (getColumnSetting @key 'type') 'text')}}
<!-- Raw value for text type -->
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} {{formatValue this}}</span>
{{else}}
<!-- Default behavior: raw value -->
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} {{formatValue this}}</span>
{{/if}}
</td>
</tr>
{{/unless}}
{{/each}}
</tbody>
</table>
</div>
{{/each}}
</div>
<div class="pagination-controls">
<button type="button" class="prev-page">Previous</button>
<span class="current-page">Data 1</span>
<button type="button" class="next-page">Next</button>
</div>
</script>
<!-- Div Template -->
<script id="div-template" type="text/x-handlebars-template">
<div class="dw-checker-results-container">
{{#each results}}
<div class="result-page" data-page="{{@index}}">
<div class="dw-checker-result-div" {{{getStyle ../resultDivider ../resultDividerWidth}}}>
{{#each this}}
{{#unless (getColumnSetting @key 'hide')}}
<div class="dw-checker-result-div-item" {{{getStyleHeader ../resultDivider ../resultDividerWidth ../headerColor}}}>
<div class="result-header" {{{getStyleHeader ../resultDivider ../resultDividerWidth ../headerColor}}}>
<span class="dw-checker-result-header">{{@key}}</span>
</div>
<div class="result-value" {{{getStyleValue ../resultDivider ../resultDividerWidth ../valueColor}}}>
{{#if (eq (getColumnSetting @key 'type') 'link_button')}}
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} <a href="{{getValueWithPrefix @key}}" class="btn btn-primary">{{getColumnSetting @key 'button_text'}}</a></span>
{{else if (eq (getColumnSetting @key 'type') 'whatsapp_button')}}
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} <a href="https://wa.me/{{getValueWithPrefix @key}}" class="btn btn-success">{{getColumnSetting @key 'button_text'}}</a></span>
{{else if (eq (getColumnSetting @key 'type') 'text')}}
<!-- Raw value for text type -->
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} {{formatValue this}}</span>
{{else}}
<!-- Default behavior: raw value -->
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} {{formatValue this}}</span>
{{/if}}
</div>
</div>
{{/unless}}
{{/each}}
</div>
</div>
{{/each}}
</div>
<div class="pagination-controls">
<button type="button" class="prev-page">Previous</button>
<span class="current-page">Data 1</span>
<button type="button" class="next-page">Next</button>
</div>
</script>
<!-- Card Template -->
<script id="cards-template" type="text/x-handlebars-template">
<div class="dw-cards-container">
{{#each results}}
<div class="result-page" data-page="{{@index}}" style="display: none;">
{{#each this}}
<div class="dw-card">
<div class="dw-card-item">
<h6 class="dw-card-title">{{@key}}</h6>
<p class="dw-card-value">
{{#if (eq (getColumnSetting @key 'type' this) 'link_button')}}
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} <a href="{{getValueWithPrefix @key}}" class="btn btn-primary">{{getColumnSetting @key 'button_text'}}</a></span>
{{else if (eq (getColumnSetting @key 'type' this) 'whatsapp_button')}}
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} <a href="https://wa.me/{{getValueWithPrefix @key}}" class="btn btn-success">{{getColumnSetting @key 'button_text' this}}</a></span>
{{else if (eq (getColumnSetting @key 'type' this) 'text')}}
<!-- Raw value for text type -->
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} {{formatValue this}}</span>
{{else}}
<!-- Default behavior: raw value -->
<span class="dw-checker-result-value">{{getColumnSetting @key 'prefix' this}} {{formatValue this}}</span>
{{/if}}
</p>
</div>
</div>
{{/each}}
</div>
{{/each}}
</div>
<div class="pagination-controls">
<button type="button" class="prev-page">Previous</button>
<span class="current-page">Data 1</span>
<button type="button" class="next-page">Next</button>
</div>
</script>
<!-- General Table Template -->
<script id="standard-table-template" type="text/x-handlebars-template">
<table class="dw-standard-table table">
<thead>
<tr>
{{#each columnHeaders}}
<th>{{this}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each results}}
<tr>
{{#each this}}
<td>{{formatValue this}}</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
</script>
<script id="repeater-template" type="text/x-handlebars-template">
{{#each fields}}
<div class="card shadow repeater-card gap-2 position-relative">
<div class="card-body">
<div class="row mb-2">
<div class="col-3"><label class="form-label fw-bold mb-0">Field ID</label></div>
<div class="col-9">
<input class="form-control field-id" value="{{@key}}" />
</div>
</div>
<div class="row mb-2">
<div class="col-3"><label class="form-label fw-bold mb-0">Kolom</label></div>
<div class="col-9">
<select name="checker[fields][{{@key}}][kolom]" class="form-select form-control border select-kolom">
{{#each kolom}}
<option value="{{this}}">{{this}}</option>
{{/each}}
</select>
</div>
</div>
<div class="row mb-2">
<div class="col-3"><label class="form-label fw-bold mb-0">Tipe</label></div>
<div class="col-9">
<select name="checker[fields][{{@key}}][type]" class="form-select form-control border select-field-type">
<option value="text" {{#ifCond type '==' 'text'}}selected{{/ifCond}}>Text</option>
<option value="select" {{#ifCond type '==' 'select'}}selected{{/ifCond}}>Select</option>
</select>
</div>
</div>
<div class="row mb-2">
<div class="col-3"><label class="form-label fw-bold mb-0">Label</label></div>
<div class="col-9">
<input name="checker[fields][{{@key}}][label]" class="form-control field-label" value="{{label}}" />
</div>
</div>
<div class="row mb-2">
<div class="col-3"><label class="form-label fw-bold mb-0">Placeholder</label></div>
<div class="col-9">
<input name="checker[fields][{{@key}}][placeholder]" class="form-control field-placeholder" value="{{placeholder}}" />
</div>
</div>
<div class="row mb-2">
<div class="col-3"><label class="form-label fw-bold mb-0">Value Matcher</label></div>
<div class="col-9">
<select name="checker[fields][{{@key}}][match]" class="form-select form-control border select-match-type">
<option value="match" {{#ifCond match '==' 'match'}}selected{{/ifCond}}>Match</option>
<option value="contain" {{#ifCond match '==' 'contain'}}selected{{/ifCond}}>Contain</option>
</select>
</div>
</div>
<div class="card-buttons d-flex gap-2 flex-column position-absolute">
<button type="button" class="btn btn-secondary py-1 px-2 move-card"><i class="bi bi-arrow-down-up"></i></button>
<button type="button" class="btn btn-danger py-1 px-2 delete-form-card"><i class="bi bi-x"></i></button>
</div>
</div>
</div>
{{/each}}
</script>