Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

121 wiersze
6.2KB

  1. <?php $jobId = (int) ($model->job['id'] ?? 0); ?>
  2. <script>
  3. window.__jobTypes = <?= json_encode($model->jobTypes, JSON_HEX_TAG | JSON_THROW_ON_ERROR) ?>;
  4. window.__initialJtId = <?= json_encode($model->form['job_type_id'], JSON_HEX_TAG | JSON_THROW_ON_ERROR) ?>;
  5. window.__initialJtVals = <?= json_encode($model->form['attribute_values'], JSON_HEX_TAG | JSON_THROW_ON_ERROR) ?>;
  6. </script>
  7. <section class="content-stack">
  8. <div class="page-toolbar">
  9. <div class="section-heading">
  10. <h1><?= e($model->title) ?></h1>
  11. <p>Update the campaign, job type, or attribute values for this job.</p>
  12. </div>
  13. <a class="button button-secondary" href="/jobs">&larr; Back to list</a>
  14. </div>
  15. <?php if ($model->saved): ?>
  16. <div class="alert alert-success" x-data="{ open: true }" x-show="open" x-transition.opacity x-init="setTimeout(() => open = false, 3500)">
  17. Job updated successfully.
  18. </div>
  19. <?php endif; ?>
  20. <section class="section-panel" x-data="jobForm(window.__jobTypes, window.__initialJtId, window.__initialJtVals)">
  21. <?php if (isset($model->errors['_token'])): ?>
  22. <div class="alert alert-error"><?= e($model->errors['_token'][0]) ?></div>
  23. <?php endif; ?>
  24. <form method="post" action="/jobs/<?= e((string) $jobId) ?>/update" class="ct-form" novalidate>
  25. <?= csrf_field() ?>
  26. <div class="form-section">
  27. <label class="field field-full">
  28. <span>Campaign <span class="required-mark">*</span></span>
  29. <select class="input<?= isset($model->errors['campaign_id']) ? ' input-error' : '' ?>"
  30. name="campaign_id" required>
  31. <option value="0">— Select a campaign —</option>
  32. <?php foreach ($model->campaigns as $c): ?>
  33. <option value="<?= e((string) $c['id']) ?>"
  34. <?= (int) $model->form['campaign_id'] === (int) $c['id'] ? 'selected' : '' ?>>
  35. <?= e($c['campaign_type_name']) ?> #<?= e((string) $c['id']) ?>
  36. </option>
  37. <?php endforeach; ?>
  38. </select>
  39. <?php if (isset($model->errors['campaign_id'])): ?>
  40. <small class="field-error"><?= e($model->errors['campaign_id'][0]) ?></small>
  41. <?php endif; ?>
  42. </label>
  43. <label class="field field-full">
  44. <span>Job type <span class="required-mark">*</span></span>
  45. <select class="input<?= isset($model->errors['job_type_id']) ? ' input-error' : '' ?>"
  46. name="job_type_id" x-model="selectedTypeId" x-on:change="onTypeChange()" required>
  47. <option value="0">— Select a job type —</option>
  48. <?php foreach ($model->jobTypes as $jt): ?>
  49. <option value="<?= e((string) $jt['id']) ?>"
  50. <?= (int) $model->form['job_type_id'] === $jt['id'] ? 'selected' : '' ?>>
  51. <?= e($jt['name']) ?>
  52. </option>
  53. <?php endforeach; ?>
  54. </select>
  55. <?php if (isset($model->errors['job_type_id'])): ?>
  56. <small class="field-error"><?= e($model->errors['job_type_id'][0]) ?></small>
  57. <?php endif; ?>
  58. </label>
  59. </div>
  60. <div class="form-section" x-show="currentAttributes.length > 0">
  61. <div class="attributes-header">
  62. <h3>Attribute values</h3>
  63. <p class="attributes-hint">Fields defined by the selected job type.</p>
  64. </div>
  65. <div class="form-grid">
  66. <template x-for="attr in currentAttributes" :key="attr.name">
  67. <label class="field">
  68. <span x-text="attr.name"></span>
  69. <template x-if="attr.type === 'boolean'">
  70. <select class="input"
  71. :name="`attribute_values[${attr.name}]`"
  72. x-on:change="attributeValues[attr.name] = $event.target.value">
  73. <option value="" :selected="!attributeValues[attr.name]">— Select —</option>
  74. <option value="true" :selected="attributeValues[attr.name] === 'true'">True</option>
  75. <option value="false" :selected="attributeValues[attr.name] === 'false'">False</option>
  76. </select>
  77. </template>
  78. <template x-if="attr.type !== 'boolean'">
  79. <input class="input" :type="inputType(attr.type)"
  80. :name="`attribute_values[${attr.name}]`"
  81. :value="attributeValues[attr.name] ?? ''"
  82. x-on:input="attributeValues[attr.name] = $event.target.value">
  83. </template>
  84. </label>
  85. </template>
  86. </div>
  87. </div>
  88. <p class="attributes-hint" x-show="selectedTypeId && currentAttributes.length === 0">
  89. This job type has no attributes defined.
  90. </p>
  91. <div class="form-actions">
  92. <button class="button button-primary" type="submit">Update Job</button>
  93. <a class="button button-secondary" href="/jobs">Cancel</a>
  94. </div>
  95. </form>
  96. <div class="delete-zone">
  97. <h4>Delete this job</h4>
  98. <p>This cannot be undone.</p>
  99. <form method="post" action="/jobs/<?= e((string) $jobId) ?>/delete"
  100. x-on:submit.prevent="confirmDelete($event)">
  101. <?= csrf_field() ?>
  102. <button type="submit" class="button button-danger">Delete Job</button>
  103. </form>
  104. </div>
  105. </section>
  106. </section>

Powered by TurnKey Linux.