summaryrefslogtreecommitdiff
path: root/app/Template/task_file
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-01-02 17:01:27 -0500
committerFrederic Guillot <fred@kanboard.net>2017-01-02 17:01:27 -0500
commit3833c12ccce59bcc49c4cfa892401973558f604d (patch)
treeb67b0e10cdc3d42e5626f728206138a444a40ed0 /app/Template/task_file
parentd49ce63e51f596ad3bf0d02b689aea673cf544f8 (diff)
Refactoring/rewrite of modal boxes handling
Diffstat (limited to 'app/Template/task_file')
-rw-r--r--app/Template/task_file/create.php43
-rw-r--r--app/Template/task_file/files.php6
-rw-r--r--app/Template/task_file/images.php3
-rw-r--r--app/Template/task_file/remove.php10
-rw-r--r--app/Template/task_file/screenshot.php10
5 files changed, 26 insertions, 46 deletions
diff --git a/app/Template/task_file/create.php b/app/Template/task_file/create.php
index e05cf829..eebb08eb 100644
--- a/app/Template/task_file/create.php
+++ b/app/Template/task_file/create.php
@@ -1,33 +1,20 @@
<div class="page-header">
<h2><?= t('Attach a document') ?></h2>
</div>
-<div id="file-done" style="display:none">
- <p class="alert alert-success">
- <?= t('All files have been uploaded successfully.') ?>
- <?= $this->url->link(t('View uploaded files'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
- </p>
-</div>
-
-<div id="file-error-max-size" style="display:none">
- <p class="alert alert-error">
- <?= t('The maximum allowed file size is %sB.', $this->text->bytes($max_size)) ?>
- <a href="#" id="file-browser"><?= t('Choose files again') ?></a>
- </p>
-</div>
-<div
- id="file-dropzone"
- data-max-size="<?= $max_size ?>"
- data-url="<?= $this->url->href('TaskFileController', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>">
- <div id="file-dropzone-inner">
- <?= t('Drag and drop your files here') ?> <?= t('or') ?> <a href="#" id="file-browser"><?= t('choose files') ?></a>
- </div>
-</div>
-
-<input type="file" name="files[]" multiple style="display:none" id="file-form-element">
+<?= $this->app->component('file-upload', array(
+ 'maxSize' => $max_size,
+ 'url' => $this->url->to('TaskFileController', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])),
+ 'labelDropzone' => t('Drag and drop your files here'),
+ 'labelOr' => t('or'),
+ 'labelChooseFiles' => t('choose files'),
+ 'labelOversize' => t('The maximum allowed file size is %sB.', $this->text->bytes($max_size)),
+ 'labelSuccess' => t('All files have been uploaded successfully.'),
+ 'labelCloseSuccess' => t('Close this window'),
+ 'labelUploadError' => t('Unable to upload this file.'),
+)) ?>
-<div class="form-actions">
- <input type="submit" value="<?= t('Upload files') ?>" class="btn btn-blue" id="file-upload-button" disabled>
- <?= t('or') ?>
- <?= $this->url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
-</div>
+<?= $this->modal->submitButtons(array(
+ 'submitLabel' => t('Upload files'),
+ 'disabled' => true,
+)) ?>
diff --git a/app/Template/task_file/files.php b/app/Template/task_file/files.php
index 32bebdcb..ffebdb84 100644
--- a/app/Template/task_file/files.php
+++ b/app/Template/task_file/files.php
@@ -15,8 +15,7 @@
<ul>
<?php if ($this->file->getPreviewType($file['name']) !== null): ?>
<li>
- <i class="fa fa-eye fa-fw"></i>
- <?= $this->url->link(t('View file'), 'FileViewerController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id']), false, 'popover') ?>
+ <?= $this->modal->large('eye', t('View file'), 'FileViewerController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?>
</li>
<?php elseif ($this->file->getBrowserViewType($file['name']) !== null): ?>
<li>
@@ -30,8 +29,7 @@
</li>
<?php if ($this->user->hasProjectAccess('TaskFileController', 'remove', $task['project_id'])): ?>
<li>
- <i class="fa fa-trash fa-fw"></i>
- <?= $this->url->link(t('Remove'), 'TaskFileController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id']), false, 'popover') ?>
+ <?= $this->modal->confirm('trash-o', t('Remove'), 'TaskFileController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?>
</li>
<?php endif ?>
</ul>
diff --git a/app/Template/task_file/images.php b/app/Template/task_file/images.php
index 8be89274..e3599441 100644
--- a/app/Template/task_file/images.php
+++ b/app/Template/task_file/images.php
@@ -24,8 +24,7 @@
</li>
<?php if ($this->user->hasProjectAccess('TaskFileController', 'remove', $task['project_id'])): ?>
<li>
- <i class="fa fa-trash fa-fw"></i>
- <?= $this->url->link(t('Remove'), 'TaskFileController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id']), false, 'popover') ?>
+ <?= $this->modal->confirm('trash-o', t('Remove'), 'TaskFileController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?>
</li>
<?php endif ?>
</ul>
diff --git a/app/Template/task_file/remove.php b/app/Template/task_file/remove.php
index 42894f05..e7ffe560 100644
--- a/app/Template/task_file/remove.php
+++ b/app/Template/task_file/remove.php
@@ -7,9 +7,9 @@
<?= t('Do you really want to remove this file: "%s"?', $this->text->e($file['name'])) ?>
</p>
- <div class="form-actions">
- <?= $this->url->link(t('Yes'), 'TaskFileController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id']), true, 'btn btn-red') ?>
- <?= t('or') ?>
- <?= $this->url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
- </div>
+ <?= $this->modal->confirmButtons(
+ 'TaskFileController',
+ 'remove',
+ array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])
+ ) ?>
</div>
diff --git a/app/Template/task_file/screenshot.php b/app/Template/task_file/screenshot.php
index 6300159f..dad8c233 100644
--- a/app/Template/task_file/screenshot.php
+++ b/app/Template/task_file/screenshot.php
@@ -6,14 +6,10 @@
<p id="screenshot-inner"><?= t('Take a screenshot and press CTRL+V or ⌘+V to paste here.') ?></p>
</div>
-<form class="popover-form" action="<?= $this->url->href('TaskFileController', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" method="post">
- <input type="hidden" name="screenshot"/>
+<form action="<?= $this->url->href('TaskFileController', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" method="post">
<?= $this->form->csrf() ?>
- <div class="form-actions">
- <button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
- <?= t('or') ?>
- <?= $this->url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
- </div>
+ <?= $this->app->component('screenshot') ?>
+ <?= $this->modal->submitButtons() ?>
</form>
<p class="alert alert-info"><?= t('This feature does not work with all browsers.') ?></p>