File

src/lib/model/prepared-item.model.ts

Description

Valid object type to be applied to a certain prepared item

Index

Properties

Properties

data
data: any
Type : any

Data to be pasted into the object types form. This data may come from default values or extraction services.

description
description: string
Type : string

Object types description

form
form: any
Type : any

Input form for the object typed

icon
icon: literal type
Type : literal type

Object types icon

label
label: string
Type : string

Object types label (title)

name
name: string
Type : string

Object types internal name

selected
selected: boolean
Type : boolean

Indicator whether or not the type is currently selected

export interface PreparedItemTemplate {
  /**
   * Templates ID
   */
  id: string;
  /**
   * Templates Title
   */
  title: string;
  /**
   * Templates description
   */
  description: string;
  types: string[];
  content: {
    path: string;
    size: number;
    mimegroup: string;
    mimetype: string;
    digest: string;
  };
  /**
   * Tags describing the template
   */
  tags: string[]
}

/**
 * File (content) attached to a prepared item
 */
export interface PreparedItemContent {
  /**
   * The contents mime type group
   */
  mimegroup: string;
  /**
   * The contents actual mime type
   */
  mimetype: string;
  /**
   * Path to the content entry
   */
  path: string;
  /**
   * Contents filesize in bytes
   */
  size: number;

  digest: string;

  existscount: number;
}

/**
 * Valid object type to be applied to a certain prepared item
 */
export interface PreparedItemType {
  /**
   * Object types internal name
   */
  name: string;
  /**
   * Indicator whether or not the type is currently selected
   */
  selected: boolean;
  /**
   * Object types label (title)
   */
  label: string;
  /**
   * Object types description
   */
  description: string;
  /**
   * Object types icon
   */
  icon: {
    id: string;
  };
  /**
   * Input form for the object typed
   */
  form: any;
  /**
   * Data to be pasted into the object types form. This data may come from default values or extraction services.
   */
  data: any;
}

/**
 * Representation of a prepared item. A prepared item is an item that is supposed to create a new dms object.
 * Adding a new object to yuuvis<sup>&reg;</sup> RAD starts with a prepared item. If all the required properties are set up, the item
 * will be used to create a new dms object.
 */
export class PreparedItem {

  /**
   * unique identifier
   */
  id: string;
  /**
   * The date (time) the item was created
   */
  created: Date;
  /**
   * Number of contents (files) attached to the item.
   */
  contentcount: number;

  /**
   * Information about the user that created the item
   */
  user: {
    id: string;
    name: string;
    title: string;
  };
  /**
   * Location (context folder) to add the item to.
   */
  parent: {
    id: string;
    title: string;
    description: string;
    type: string;
  };
  /**
   * The state of the prepared item
   */
  state: {
    /**
     * UNKNOWN: no object type selected yet, so we don't know which kind of content is supported
     * NOCONTENTALLOWED: no content attachable
     * REQUIRED: content required (e.g. for template types)
     * OPTIONAL: one may or may not add content
     */
    contentstate: 'UNKNOWN' | 'NOCONTENTALLOWED' | 'REQUIRED' | 'OPTIONAL',
    typeselected: boolean,
    typeselectedallowed: boolean,
    hasallowedtypes: boolean,
    contentset: boolean,
    multicontent: boolean,
    templateset: boolean,
    parentisroot: boolean,
    parentset: boolean
  };
  /**
   * The target object type selected for the prepared item. To be able to add new items to yuuvis<sup>&reg;</sup> RAD an object type is required to be set up.
   */
  selectedtype: {
    name: string,
    label: string,
    description: string,
  };
  /**
   * New dms objects may be created from a template. This property stores information about the selected template.
   */
  template: {
    id: string,
    description: string,
    title: string,
  };
  /**
   * Prepared items are able to perform bulk operations to create new dms objects. So you may add a bunch of files and decide to create one
   * prepared item from it. When all the required properties are set up, the prepared item will create a dms object for each of those files.
   *
   * Contents property holds the list of content files attached to the prepared item
   */
  contents: PreparedItemContent[];
  /**
   * Based on target location and attached files this property holds a collection of valid object types for the prepared item
   */
  types: PreparedItemType[];
  /**
   * Prepared items title
   */
  get title() {
    return this.selectedtype ? this.selectedtype.label : '';
  }

  /**
   * Creates a new instance
   * @param json The JSON object received from the backend. This will be used to construct the new prepared item instance
   */
  constructor(json: any) {
    Object.assign(this, json);
  }

  /**
   * Returns true if the preparedItem contains content (template or actual file), false otherwise
   */
  hasContent(): boolean {
    return !!this.template || this.contentcount > 0;
  }

  /**
   * Retrieves the prepared items selected type object from the list
   * of available types.
   * @returns The type object that is selected or NULL
   */
  getSelectedTypeObject() {
    return this.types.find(t => t.selected);
  }
}

results matching ""

    No results matching ""