N°1123.4 AttributeImage: Better UI when editing in console. Also, export was showing url for empty value.

SVN:trunk[5060]
This commit is contained in:
Guillaume Lajarige
2017-10-20 13:22:38 +00:00
parent b7c4e084f3
commit 5c34e3d988
5 changed files with 22 additions and 16 deletions

View File

@@ -1671,7 +1671,7 @@ class utils
* - an http(s) URL
* - the local file system (but only if you are an administrator)
* @param string $sPath
* @return string[]|NULL[]
* @return ormDocument|null
* @throws Exception
*/
public static function FileGetContentsAndMIMEType($sPath)
@@ -1687,15 +1687,6 @@ class utils
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12.xlsx',
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
@@ -1722,8 +1713,13 @@ class utils
$sMimeType = 'text/plain'; // Default MIME Type: treat the file as a bunch a characters...
$sFileName = 'uploaded-file'; // Default name for downloaded-files
$sExtension = '.txt'; // Default file extension in case we don't know the MIME Type
if (static::IsURL($sPath))
if(empty($sPath))
{
// Empty path (NULL or '') means that there is no input, making an empty document.
$oUploadedDoc = new ormDocument('', '', '');
}
elseif (static::IsURL($sPath))
{
if ($oUploadedDoc = static::IsSelfURL($sPath))
{

View File

@@ -5402,8 +5402,9 @@ class AttributeBlob extends AttributeDefinition
public function GetAsCSV($sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true, $bConvertToPlainText = false)
{
$sAttCode = $this->GetCode();
if ($sValue instanceof ormDocument)
if ($sValue instanceof ormDocument && !$sValue->IsEmpty())
{
IssueLog::Info(print_r($sValue, true));
return $sValue->GetDownloadURL(get_class($oHostObject), $oHostObject->GetKey(), $sAttCode);
}
return ''; // Not exportable in CSV !
@@ -5527,7 +5528,7 @@ class AttributeImage extends AttributeBlob
*/
public function CheckFormat($value)
{
if ($value instanceof ormDocument)
if ($value instanceof ormDocument && !$value->IsEmpty())
{
return ($value->GetMainMimeType() == 'image');
}

View File

@@ -85,6 +85,9 @@ table.listResults td .view-image img {
.edit-image .view-image {
display: inline-block;
}
.edit-image .view-image img[src=""], .edit-image .view-image img[src="null"] {
visibility: hidden;
}
.edit-image .view-image.dirty.compat {
background-image: url("ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png");
}

View File

@@ -107,6 +107,12 @@ table.listResults td .view-image {
.view-image {
display: inline-block;
img[src=""],
img[src="null"] {
// Hiding "broken" image when src is not set
visibility: hidden;
}
&.dirty {
// The image will be modified when saving the changes
@@ -835,7 +841,7 @@ table.listResults tr.even td.truncated, .wizContainer table.listResults tr.even
}
/* Beware: IE6 does not support multiple selector with multiple classes, only the last class is used */
table.listResults tr.even td.hover.truncated, , .wizContainer table.listResults tr.even td.hover.truncated {
table.listResults tr.even td.hover.truncated, .wizContainer table.listResults tr.even td.hover.truncated {
background: #fdf5d0 url(../images/truncated.png?v=#{$version}) bottom repeat-x;
}

View File

@@ -28,7 +28,7 @@ $(function()
// the constructor
_create: function () {
var me = this;
me.bLoadedEmpty = (me.options.current_image_url == '');
me.bLoadedEmpty = (me.options.current_image_url == '' || me.options.current_image_url == null);
var sMarkup = '';
sMarkup += '<input type="hidden" id="do_remove_' + me.options.input_name + '" name="' + me.options.input_name + '[remove]" value="0"/>';