PluginProbe
Elementor Website Builder – more than just a page builder / 3.8.0-beta1
Elementor Website Builder – more than just a page builder v3.8.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 All 457 releases
elementor / app / modules / kit-library / assets / js / models / kit.js

kit.js in Elementor Website Builder – more than just a page builder 3.8.0-beta1, at app/modules/kit-library/assets/js/models/kit.js

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import BaseModel from './base-model';
2 import Document from './document';
3
4 /**
5 * @typedef {import('./content-type')} ContentType
6 */
7 export default class Kit extends BaseModel {
8 id = '';
9 title = '';
10 description = '';
11 isFavorite = false;
12 thumbnailUrl = null;
13 previewUrl = '';
14 accessLevel = 0;
15 trendIndex = null;
16 popularityIndex = null;
17 featuredIndex = null;
18 createdAt = null;
19 updatedAt = null;
20 keywords = [];
21 taxonomies = [];
22 documents = [];
23
24 /**
25 * Create a kit from server response
26 *
27 * @param {Kit} kit
28 */
29 static createFromResponse( kit ) {
30 return new Kit().init( {
31 id: kit.id,
32 title: kit.title,
33 description: kit.description,
34 isFavorite: kit.is_favorite,
35 thumbnailUrl: kit.thumbnail_url,
36 previewUrl: kit.preview_url,
37 accessLevel: kit.access_level,
38 trendIndex: kit.trend_index,
39 popularityIndex: kit.popularity_index,
40 featuredIndex: kit.featured_index,
41 // TODO: Remove when the API is stable (when date params always exists)
42 createdAt: kit.created_at ? new Date( kit.created_at ) : null,
43 updatedAt: kit.updated_at ? new Date( kit.updated_at ) : null,
44 //
45 keywords: kit.keywords,
46 taxonomies: kit.taxonomies,
47 documents: kit.documents
48 ? kit.documents.map( ( document ) => Document.createFromResponse( document ) )
49 : [],
50 } );
51 }
52
53 /**
54 * Get content types as param and group all the documents based on it.
55 *
56 * @param {ContentType[]} contentTypes
57 * @return {ContentType[]} content types
58 */
59 getDocumentsByTypes( contentTypes ) {
60 return contentTypes.map( ( contentType ) => {
61 contentType = contentType.clone();
62
63 contentType.documents = this.documents
64 .filter( ( document ) => contentType.documentTypes.includes( document.documentType ) );
65
66 return contentType;
67 } );
68 }
69 }
70