idea-toolbox
Advanced tools
Comparing version 7.0.12 to 7.0.13
@@ -0,16 +1,18 @@ | ||
import { Label } from './label.model'; | ||
import { Languages } from './languages.model'; | ||
import { Resource } from './resource.model'; | ||
/** | ||
* An attachment to attach to a resource. | ||
* An attachment to stick to an entity. | ||
*/ | ||
export declare class Attachment extends Resource { | ||
/** | ||
* The id of the attachment. | ||
* The ID of the attachment. | ||
*/ | ||
attachmentId: string; | ||
/** | ||
* The name of the resource. This can be changed when attaching to the resource. | ||
* The name of the attachment. | ||
*/ | ||
name: string; | ||
/** | ||
* The format of the resource. (e.g. 'jpg', 'pdf'). | ||
* The format of the attachment, without a prefixing dot (e.g. 'jpg', 'pdf'). | ||
*/ | ||
@@ -21,2 +23,47 @@ format: string; | ||
validate(): string[]; | ||
/** | ||
* Get the filename (`name.format`) of the attachment. | ||
*/ | ||
getFilename(): string; | ||
} | ||
/** | ||
* A section to group a list of attachments. | ||
*/ | ||
export declare class AttachmentSection extends Resource { | ||
/** | ||
* The name of the section (multilanguage). | ||
*/ | ||
name: Label; | ||
/** | ||
* The description of the section (multilanguage). | ||
*/ | ||
description: Label; | ||
/** | ||
* The list of attachments in the section. | ||
*/ | ||
attachments: Attachment[]; | ||
load(x: any, languages: Languages): void; | ||
validate(languages: Languages): string[]; | ||
} | ||
/** | ||
* A block of reorderable sections each containing a list of attachments. | ||
* Use it when you need to organize the attachments in sections or categories. | ||
*/ | ||
export declare class AttachmentSections extends Resource { | ||
/** | ||
* Ordered list of the sections (keys) to expect in the block. | ||
* Example: `['flowers', 'burgers', ...]`. | ||
*/ | ||
sectionsLegend: string[]; | ||
/** | ||
* Object containg attributes of type AttachmentSection; e.g. | ||
* ``` | ||
* sections.flowers: AttachmentSection; | ||
* sections.burgers: AttachmentSection; | ||
* ... | ||
* ``` | ||
*/ | ||
sections: Record<string, AttachmentSection>; | ||
load(x: any, languages: Languages): void; | ||
validate(languages: Languages): string[]; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Attachment = void 0; | ||
exports.AttachmentSections = exports.AttachmentSection = exports.Attachment = void 0; | ||
const label_model_1 = require("./label.model"); | ||
const resource_model_1 = require("./resource.model"); | ||
/** | ||
* An attachment to attach to a resource. | ||
* An attachment to stick to an entity. | ||
*/ | ||
@@ -30,3 +31,45 @@ class Attachment extends resource_model_1.Resource { | ||
} | ||
/** | ||
* Get the filename (`name.format`) of the attachment. | ||
*/ | ||
getFilename() { | ||
return this.name.concat('.', this.format); | ||
} | ||
} | ||
exports.Attachment = Attachment; | ||
/** | ||
* A section to group a list of attachments. | ||
*/ | ||
class AttachmentSection extends resource_model_1.Resource { | ||
load(x, languages) { | ||
super.load(x); | ||
this.name = new label_model_1.Label(x.name, languages); | ||
this.description = new label_model_1.Label(x.description, languages); | ||
this.attachments = this.cleanArray(x.attachments, a => new Attachment(a)); | ||
} | ||
validate(languages) { | ||
const e = super.validate(); | ||
if (this.name.validate(languages).length) | ||
e.push('name'); | ||
return e; | ||
} | ||
} | ||
exports.AttachmentSection = AttachmentSection; | ||
/** | ||
* A block of reorderable sections each containing a list of attachments. | ||
* Use it when you need to organize the attachments in sections or categories. | ||
*/ | ||
class AttachmentSections extends resource_model_1.Resource { | ||
load(x, languages) { | ||
super.load(x, languages); | ||
this.sectionsLegend = this.cleanArray(x.sectionsLegend, String); | ||
this.sections = {}; | ||
this.sectionsLegend.forEach(s => (this.sections[s] = new AttachmentSection(x.sections[s], languages))); | ||
} | ||
validate(languages) { | ||
const e = super.validate(); | ||
this.sectionsLegend.forEach(s => this.sections[s].validate(languages).forEach(es => e.push(`${s}.${es}`))); | ||
return e; | ||
} | ||
} | ||
exports.AttachmentSections = AttachmentSections; |
{ | ||
"name": "idea-toolbox", | ||
"version": "7.0.12", | ||
"version": "7.0.13", | ||
"description": "IDEA's utility functions", | ||
@@ -5,0 +5,0 @@ "license": "MPL-2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
264280
7339