| | |
| | | $dataIgnore = $this->useCRUDjs ? '' : ' data-ignore'; |
| | | ?> |
| | | <section class="items-list <?= esc_attr($this->dataType) ?> crud" data-content="<?= esc_attr($this->dataType) ?>" data-singular="<?=$this->singular?>" data-plural="<?=$this->plural?>" data-view="<?= $this->defaultView?>"<?=$dataIgnore?>> |
| | | <div class="wrap"> |
| | | <div id="item-wrap"> |
| | | <?php |
| | | $this->renderControlsAndFilters(); |
| | | |
| | |
| | | $form = ob_get_clean(); |
| | | echo jvbNewModal( |
| | | 'date-range', |
| | | 'date-range', |
| | | 'Filter Results by Date:', |
| | | $form |
| | | ); |
| | |
| | | ?> |
| | | <template class="contentTable"> |
| | | <form class="table" |
| | | data-save="content" |
| | | data-content="<?= esc_attr($this->dataType) ?>" |
| | | data-form-id="content-table-<?= esc_attr($this->dataType) ?>" |
| | | <?= $permissions?>> |
| | |
| | | <?= $this->renderItemSelect() ?> |
| | | </td> |
| | | <?php |
| | | if (array_key_exists('status', $this->fields)){ |
| | | if (array_key_exists('post_status', $this->fields)){ |
| | | ?> |
| | | <td class="status" data-field="post_status"> |
| | | <td class="post_status" data-field="post_status" data-field-type="radio"> |
| | | <?= $this->renderStatusRadios() ?> |
| | | </td> |
| | | <?php |
| | |
| | | 'radio' |
| | | ]; |
| | | foreach ($this->fields as $name => $config): |
| | | if (array_key_exists('hidden', $config) || $name === 'status'){ |
| | | if ((array_key_exists('hidden', $config) && $config['hidden'] === true) || $name === 'post_status'){ |
| | | continue; |
| | | } |
| | | $makeThisDetailed = (in_array($config['type'], $makeDetails)); |
| | |
| | | ?> |
| | | <template class="contentTable"> |
| | | <form class="table" |
| | | data-save="content" |
| | | data-content="<?= esc_attr($this->dataType) ?>" |
| | | data-form-id="content-table-<?= esc_attr($this->dataType) ?>"> |
| | | <?= jvbFormStatus() ?> |
| | |
| | | </td> |
| | | <?php |
| | | foreach ($this->fields as $name => $config) { |
| | | if(array_key_exists('hidden', $config) || $name === 'post_status') { |
| | | if((array_key_exists('hidden', $config) && $config['hidden'] === true) || $name === 'post_status') { |
| | | continue; |
| | | } |
| | | if (!in_array($name, $this->timelineUniqueFields)) { |
| | |
| | | * Render table header |
| | | */ |
| | | protected function renderTableHeader(): string { |
| | | ob_start(); |
| | | |
| | | ?> |
| | | <tr> |
| | | $out = '<tr> |
| | | <th scope="col" class="select-header"> |
| | | <input type="checkbox" id="select-all" name="select-all"> |
| | | <label for="select-all">All</label> |
| | | </th> |
| | | <?php if (array_key_exists('status', $this->fields)) { ?> |
| | | <th scope="col" class="status-header">Status</th> |
| | | <?php } ?> |
| | | <?php foreach ($this->fields as $name => $config): |
| | | if (array_key_exists('hidden', $config) || $name === 'status'){ |
| | | continue; |
| | | } |
| | | ?> |
| | | <th scope="col" class="show-<?= esc_attr($name) ?>"<?= (in_array($name, $this->stuck)) ? ' data-stuck':''?>> |
| | | <?= esc_html($config['label']) ?> |
| | | </th> |
| | | <?php endforeach; |
| | | if (!empty($this->itemActions)) { |
| | | ?> |
| | | <th scope="col" class="show-actions"> |
| | | Actions |
| | | </th> |
| | | <?php |
| | | } |
| | | ?> |
| | | </th>'; |
| | | |
| | | </tr> |
| | | <?php |
| | | return ob_get_clean(); |
| | | if (array_key_exists('post_status', $this->fields)){ |
| | | $out .= '<th scope="col" class="status-header">Status</th>'; |
| | | } |
| | | |
| | | foreach ($this->fields as $name => $config) { |
| | | if ($name === 'post_status' || (array_key_exists('hidden', $config) && $config['hidden'] === true)) { |
| | | continue; |
| | | } |
| | | $out .= sprintf( |
| | | '<th scope="col" class="show-%s"%s>%s</th>', |
| | | esc_attr($name), |
| | | in_array($name, $this->stuck) ? ' data-stuck' : '', |
| | | esc_html($config['label']) |
| | | ); |
| | | } |
| | | |
| | | if (!empty($this->itemActions)) { |
| | | $out .= '<th scope="col" class="show-actions">Actions</th>'; |
| | | } |
| | | $out .= '</tr>'; |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | protected function renderTimelineTableHeader(): string { |
| | | ob_start(); |
| | | |
| | | ?> |
| | | <tr> |
| | | $out = '<tr> |
| | | <th scope="col" class="select-header"> |
| | | <input type="checkbox" id="select-all" name="select-all"> |
| | | <label for="select-all">All</label> |
| | | </th> |
| | | <th scope="col" class="show-post_status"> |
| | | Status |
| | | </th> |
| | | <?php foreach ($this->fields as $name => $config): |
| | | if (array_key_exists('hidden', $config) || $name === 'post_status'){ |
| | | continue; |
| | | } |
| | | ?> |
| | | <th scope="col" class="show-<?= esc_attr($name) ?>"<?= (in_array($name, $this->stuck)) ? ' data-stuck':''?>> |
| | | <?= esc_html($config['label']) ?> |
| | | </th> |
| | | <?php endforeach; ?> |
| | | </tr> |
| | | <?php |
| | | return ob_get_clean(); |
| | | </th>'; |
| | | |
| | | foreach ($this->fields as $name => $config) { |
| | | if ($name === 'post_status' || (array_key_exists('hidden', $config) && $config['hidden'] === true)) { |
| | | continue; |
| | | } |
| | | $out .= sprintf( |
| | | '<th scope="col" class="show-%s"%s>%s</th>th>', |
| | | esc_attr($name), |
| | | in_array($name, $this->stuck) ? ' data-stuck':'', |
| | | esc_html($config['label']) |
| | | ); |
| | | } |
| | | $out .= '</tr>'; |
| | | return $out; |
| | | } |
| | | |
| | | /** |
| | |
| | | return ob_get_clean(); |
| | | } |
| | | |
| | | protected function renderStatusRadios(): string { |
| | | ob_start(); |
| | | ?> |
| | | <div class="radio-options status-options row" data-field="post_status" data-field-type="radio"> |
| | | <?php foreach ($this->statuses as $status): |
| | | if ($status === 'all') continue; |
| | | if (!array_key_exists($status, $this->allowedStatuses)) continue; |
| | | $config = $this->allowedStatuses[$status]; |
| | | ?> |
| | | protected function renderStatusRadios(): string |
| | | { |
| | | $out = '<div class="radio-options status-options row">'; |
| | | foreach ($this->statuses as $status) { |
| | | if ($status === 'all' || !array_key_exists($status, $this->allowedStatuses)) continue; |
| | | $config = $this->allowedStatuses[$status]; |
| | | |
| | | <input type="radio" |
| | | $out .= sprintf( |
| | | '<input type="radio" |
| | | name="post_status" |
| | | id="status-<?= esc_attr($status) ?>" |
| | | value="<?= esc_attr($status) ?>"> |
| | | <label for="status-<?= esc_attr($status) ?>"> |
| | | <?= jvbDashIcon($config['icon']) ?> |
| | | <span class="screen-reader-text"><?= esc_html($config['label']) ?></span> |
| | | </label> |
| | | <?php endforeach; ?> |
| | | <span class="validation-message" hidden role="alert"></span> |
| | | </div> |
| | | <?php |
| | | return ob_get_clean(); |
| | | id="post_status-%s" |
| | | class="btn" |
| | | value="%s"> |
| | | <label for="post_status-%s" title="%s"> |
| | | %s |
| | | <span class="screen-reader-text">%s</span> |
| | | </label>', |
| | | esc_attr($status), |
| | | esc_attr($status), |
| | | esc_attr($status), |
| | | esc_html($config['label']), |
| | | jvbDashIcon($config['icon']), |
| | | esc_html($config['label']) |
| | | ); |
| | | } |
| | | $out .= '<span class="validation-message" hidden role="alert"></span> |
| | | </div>'; |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | echo jvbNewModal( |
| | | 'create', |
| | | 'create', |
| | | 'Creating <span class="count"></span> New '.$this->singular, |
| | | str_replace('edit-form"', 'create-form" data-noautosave', $this->editForm()) |
| | | ); |
| | |
| | | protected function editForm():string |
| | | { |
| | | ob_start(); |
| | | /* <form class="edit-form" data-save="content" data-form-id="edit-<?=$this->dataType?>" data-autosave<?= ($this->isTimeline) ? ' data-timeline' : ''*/ |
| | | ?> |
| | | <form class="edit-form" data-save="content" data-form-id="edit-<?=$this->dataType?>" data-autosave<?= ($this->isTimeline) ? ' data-timeline' : ''?>> |
| | | |
| | | <form class="edit-form" data-form-id="edit-<?=$this->dataType?>" data-autosave<?= ($this->isTimeline) ? ' data-timeline' : ''?>> |
| | | <?= jvbFormStatus() ?> |
| | | <input type="hidden" name="form-id" value="<?=uniqid('new-')?>" /> |
| | | <input type="hidden" name="content" value="<?=$this->dataType?>" /> |
| | | <div class="fields"> |
| | | <?php |
| | | if (!empty($this->statuses)) { |
| | | if (empty($this->sections) && !empty($this->statuses)) { |
| | | echo Form::render('post_status', '', $this->getStatusFieldConfig('edit-')); |
| | | } |
| | | |
| | |
| | | 'icon' => $config['icon'] |
| | | ]; |
| | | } |
| | | |
| | | $tabs[$slug] = array_merge([ |
| | | 'title' => $config['label'], |
| | | 'title' => $config['title'], |
| | | 'content' => '', |
| | | 'description' => $config['description']??'', |
| | | ], $section); |
| | |
| | | foreach ($first as $f) { |
| | | if (array_key_exists($f, $fields)) { |
| | | if ($tabs) { |
| | | $tabs['basic']['content'] .= Form::render($f, '', $fields[$f]); |
| | | $tabs['main']['content'] .= Form::render($f, '', $fields[$f]); |
| | | } else { |
| | | echo Form::render($f, '', $fields[$f]); |
| | | } |
| | |
| | | |
| | | $fields = $this->nonTimelineFields; |
| | | } |
| | | |
| | | foreach ($fields as $n => $config) { |
| | | if (in_array($config['type'], ['taxonomy', 'selector'])) { |
| | | $config = array_merge($config, $this->taxConfig($config['taxonomy'], $config['label'])); |
| | | } |
| | | if ($tabs) { |
| | | $section = (array_key_exists('section', $config)) ? $config['section'] : 'basic'; |
| | | $section = (array_key_exists('section', $config)) && !empty($config['section']) ? $config['section'] : 'main'; |
| | | $tabs[$section]['content'] .= Form::render($n, '', $config); |
| | | } else { |
| | | echo Form::render($n, '', $config); |
| | |
| | | { |
| | | echo jvbNewModal( |
| | | 'edit', |
| | | 'edit', |
| | | 'Edit your '.$this->singular, |
| | | $this->editForm() |
| | | ); |
| | |
| | | { |
| | | if (empty($this->bulkActions)) return; |
| | | ob_start(); |
| | | /* <form class="bulk-edit-form" data-save="content" data-form-id="bulk-edit-<?=$this->dataType?>">*/ |
| | | ?> |
| | | <form class="bulk-edit-form" data-save="content" data-form-id="bulk-edit-<?=$this->dataType?>"> |
| | | |
| | | <form class="bulk-edit-form" data-form-id="bulk-edit-<?=$this->dataType?>"> |
| | | <?= jvbFormStatus() ?> |
| | | <div class="selected"></div> |
| | | <p class="description">You can unselect items by clicking the image here.</p> |
| | |
| | | $form = ob_get_clean(); |
| | | echo jvbNewModal( |
| | | 'bulkEdit', |
| | | 'bulkEdit', |
| | | 'Bulk Edit <span class="selected"></span> '.$this->plural, |
| | | $form |
| | | ); |