Permalink
Browse files

FIX UploadField validation error and styles

UploadField now return the validator's error message instead of 403. Plus nicer layout for error messages.
  • Loading branch information...
colymba committed Aug 20, 2013
1 parent 98c01a3 commit 02bceca9b478358bdd569c16818d3be2467beb64
Showing with 58 additions and 4 deletions.
  1. +7 −0 css/UploadField.css
  2. +0 −1 forms/UploadField.php
  3. +5 −3 javascript/UploadField_downloadtemplate.js
  4. +46 −0 scss/UploadField.scss
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1235,7 +1235,6 @@ public function upload(SS_HTTPRequest $request) {
// Format response with json
$response = new SS_HTTPResponse(Convert::raw2json(array($return)));
$response->addHeader('Content-Type', 'text/plain');
- if(!empty($return['error'])) $response->setStatusCode(403);
return $response;
}
@@ -1,9 +1,11 @@
window.tmpl.cache['ss-uploadfield-downloadtemplate'] = tmpl(
'{% for (var i=0, files=o.files, l=files.length, file=files[0]; i<l; file=files[++i]) { %}' +
'<li class="ss-uploadfield-item template-download{% if (file.error) { %} ui-state-error{% } %}" data-fileid="{%=file.id%}">' +
- '<div class="ss-uploadfield-item-preview preview"><span>' +
- '<img src="{%=file.thumbnail_url%}" alt="" />' +
- '</span></div>' +
+ '{% if (file.thumbnail_url) { %}' +
+ '<div class="ss-uploadfield-item-preview preview"><span>' +
+ '<img src="{%=file.thumbnail_url%}" alt="" />' +
+ '</span></div>' +
+ '{% } %}' +
'<div class="ss-uploadfield-item-info">' +
'{% if (!file.error) { %}' +
'<input type="hidden" name="{%=file.fieldname%}[Files][]" value="{%=file.id%}" />' +
View
@@ -85,6 +85,52 @@
}
}
}
+
+ //Upload/Validation error
+ &.ui-state-error
+ {
+ .ss-uploadfield-item-preview {
+ width: auto;
+ height: auto;
+ margin-right: 15px;
+ }
+
+ .ss-uploadfield-item-info {
+ margin-left: 0;
+
+ .ss-uploadfield-item-name {
+ float: left;
+ width: 70%;
+ height: auto;
+
+ .name
+ {
+ float: left;
+ width: 100%;
+ margin-bottom: 5px;
+ }
+
+ .ss-uploadfield-item-status {
+ float: left;
+ width: 100%;
+ padding: 0;
+ text-align: left;
+ }
+ }
+
+ .ss-uploadfield-item-actions {
+ float: right;
+ width: 5%;
+ min-height: 0;
+ margin: 0;
+
+ .ss-uploadfield-item-cancel {
+ position: relative;
+ top: auto;
+ }
+ }
+ }
+ }
}
.ss-ui-button {
display: block;

0 comments on commit 02bceca

Please sign in to comment.