25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
7.4KB

  1. <?php $campaignId = (int) ($model->campaign['id'] ?? 0); ?>
  2. <script>
  3. window.__campaignTypes = <?= json_encode($model->campaignTypes, JSON_HEX_TAG | JSON_THROW_ON_ERROR) ?>;
  4. window.__initialTypeId = <?= json_encode($model->form['campaign_type_id'], JSON_HEX_TAG | JSON_THROW_ON_ERROR) ?>;
  5. window.__initialValues = <?= 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 name, type, or attribute values.</p>
  12. </div>
  13. <a class="button button-secondary" href="/campaigns">&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. Campaign updated successfully.
  18. </div>
  19. <?php endif; ?>
  20. <section class="section-panel" x-data="campaignForm(window.__campaignTypes, window.__initialTypeId, window.__initialValues)">
  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="/campaigns/<?= e((string) $campaignId) ?>/update" class="ct-form" novalidate>
  25. <?= csrf_field() ?>
  26. <div class="form-section">
  27. <label class="field field-full">
  28. <span>Campaign type <span class="required-mark">*</span></span>
  29. <select
  30. class="input<?= isset($model->errors['campaign_type_id']) ? ' input-error' : '' ?>"
  31. name="campaign_type_id"
  32. x-model="selectedTypeId"
  33. x-on:change="onTypeChange()"
  34. required
  35. >
  36. <option value="0">— Select a campaign type —</option>
  37. <?php foreach ($model->campaignTypes as $type): ?>
  38. <option
  39. value="<?= e((string) $type['id']) ?>"
  40. <?= (int) $model->form['campaign_type_id'] === $type['id'] ? 'selected' : '' ?>
  41. ><?= e($type['name']) ?></option>
  42. <?php endforeach; ?>
  43. </select>
  44. <?php if (isset($model->errors['campaign_type_id'])): ?>
  45. <small class="field-error"><?= e($model->errors['campaign_type_id'][0]) ?></small>
  46. <?php endif; ?>
  47. </label>
  48. </div>
  49. <div class="form-section" x-show="currentAttributes.length > 0">
  50. <div class="attributes-header">
  51. <h3>Attribute values</h3>
  52. <p class="attributes-hint">Fields defined by the selected campaign type.</p>
  53. </div>
  54. <div class="form-grid">
  55. <template x-for="attr in currentAttributes" :key="attr.name">
  56. <label class="field">
  57. <span x-text="attr.name"></span>
  58. <template x-if="attr.type === 'boolean'">
  59. <select class="input"
  60. :name="`attribute_values[${attr.name}]`"
  61. x-on:change="attributeValues[attr.name] = $event.target.value">
  62. <option value="" :selected="!attributeValues[attr.name]">— Select —</option>
  63. <option value="true" :selected="attributeValues[attr.name] === 'true'">True</option>
  64. <option value="false" :selected="attributeValues[attr.name] === 'false'">False</option>
  65. </select>
  66. </template>
  67. <template x-if="attr.type !== 'boolean'">
  68. <input class="input"
  69. :type="inputType(attr.type)"
  70. :name="`attribute_values[${attr.name}]`"
  71. :value="attributeValues[attr.name] ?? ''"
  72. x-on:input="attributeValues[attr.name] = $event.target.value">
  73. </template>
  74. </label>
  75. </template>
  76. </div>
  77. </div>
  78. <p class="attributes-hint" x-show="selectedTypeId && currentAttributes.length === 0">
  79. This campaign type has no attributes defined.
  80. </p>
  81. <div class="form-actions">
  82. <button class="button button-primary" type="submit">Update Campaign</button>
  83. <a class="button button-secondary" href="/campaigns">Cancel</a>
  84. </div>
  85. </form>
  86. <div class="delete-zone">
  87. <h4>Delete this campaign</h4>
  88. <p>This cannot be undone.</p>
  89. <form
  90. method="post"
  91. action="/campaigns/<?= e((string) $campaignId) ?>/delete"
  92. x-on:submit.prevent="confirmDelete($event)"
  93. >
  94. <?= csrf_field() ?>
  95. <button type="submit" class="button button-danger">Delete Campaign</button>
  96. </form>
  97. </div>
  98. </section>
  99. <section class="section-panel" x-data="campaignJobsTable(<?= $campaignId ?>)">
  100. <div class="panel-header">
  101. <div>
  102. <h2>Jobs</h2>
  103. <p>All jobs attached to this campaign.</p>
  104. </div>
  105. <div class="panel-actions">
  106. <button class="button button-secondary button-sm" type="button" x-cloak x-show="!isVisible" x-on:click="showTable()">
  107. Show Jobs
  108. </button>
  109. <a class="button button-primary button-sm" href="/jobs/create">+ New Job</a>
  110. <button class="button button-secondary button-sm" type="button" x-cloak x-show="isVisible" x-on:click="reloadTable()">Refresh</button>
  111. <button class="button button-secondary button-sm" type="button" x-cloak x-show="isVisible" x-on:click="hideTable()">Hide</button>
  112. </div>
  113. </div>
  114. <div x-cloak x-show="isVisible" x-transition.opacity>
  115. <div class="inline-indicator" x-show="isLoading">Loading jobs...</div>
  116. <div class="alert alert-error" x-show="errorMessage" x-text="errorMessage"></div>
  117. <div class="empty-state" x-show="!isLoading && !errorMessage && hasLoaded && groups.length === 0">
  118. <p>No jobs are attached to this campaign.</p>
  119. </div>
  120. <div class="job-type-table-stack" x-show="groups.length > 0">
  121. <template x-for="group in groups" :key="group.id">
  122. <section class="job-type-table-group">
  123. <div class="job-type-table-heading">
  124. <h3 x-text="group.name"></h3>
  125. <span x-text="group.rows.length + (group.rows.length === 1 ? ' job' : ' jobs')"></span>
  126. </div>
  127. <div :id="group.elementId" class="tabulator-host"></div>
  128. </section>
  129. </template>
  130. </div>
  131. </div>
  132. </section>
  133. </section>

Powered by TurnKey Linux.