Minor - Fix document edition

pull/3432/head
Julio Montoya 4 years ago
parent 6dca6a1a19
commit 44ae74c73f
  1. 5
      assets/vue/components/documents/FormNewDocument.vue
  2. 6
      assets/vue/views/documents/UpdateFile.vue
  3. 18
      src/CoreBundle/Entity/ResourceFile.php
  4. 2
      src/CoreBundle/Entity/ResourceNode.php

@ -20,7 +20,7 @@
<editor
id="item_content"
v-if="item.resourceNode && item.resourceNode.fileEditableText || item.newDocument"
v-if="(item.resourceNode && item.resourceNode.resourceFile && item.resourceNode.resourceFile.text) || item.newDocument"
v-model="item.contentFile"
:error-messages="contentFileErrors"
required
@ -73,7 +73,6 @@ import has from 'lodash/has';
import { validationMixin } from 'vuelidate';
import { required } from 'vuelidate/lib/validators';
//import UploadAdapter from './UploadAdapter';
import Editor from '../Editor'
export default {
@ -119,7 +118,7 @@ export default {
contentFileErrors() {
const errors = [];
if (this.item.resourceNode && this.item.resourceNode.fileEditableText) {
if (this.item.resourceNode && this.item.resourceNode.resourceFile && this.item.resourceNode.resourceFile.text) {
if (!this.$v.item.contentFile.$dirty) return errors;
has(this.violations, 'contentFile') && errors.push(this.violations.contentFile);
!this.$v.item.contentFile.required && errors.push(this.$t('Content is required'));

@ -1,20 +1,20 @@
<template>
<div>
<DocumentsForm
v-if="!isLoading"
v-if="item && !isLoading"
ref="updateForm"
:values="item"
:errors="violations"
/>
<ResourceLinkForm
v-if="item"
v-if="item && !isLoading"
ref="resourceLinkForm"
:values="item"
/>
<Toolbar
v-if="!isLoading"
v-if="item && !isLoading"
:handle-submit="onSendForm"
:handle-reset="resetForm"
:handle-delete="del"

@ -154,13 +154,15 @@ class ResourceFile
protected ?bool $video;
/**
* @ORM\Column(name="description", type="text", nullable=true)
* @Groups({"resource_file:read", "resource_node:read", "document:read"})
*/
protected ?string $description;
protected ?bool $text;
/**
* Constructor.
* @ORM\Column(name="description", type="text", nullable=true)
*/
protected ?string $description;
public function __construct()
{
$this->metadata = [];
@ -173,6 +175,16 @@ class ResourceFile
return $this->getOriginalName();
}
public function isText(): bool
{
$mimeType = $this->getMimeType();
if (false !== strpos($mimeType, 'text')) {
return true;
}
return false;
}
public function isImage(): bool
{
$mimeType = $this->getMimeType();

@ -198,7 +198,7 @@ class ResourceNode
$this->resourceLinks = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->createdAt = new \DateTime();
$this->editableContent = false;
$this->fileEditableText = false;
}
/**

Loading…
Cancel
Save