Mark as deprecated an recommend vue instead
This commit is contained in:
2
src/scripts/js/es6/common/templates/DEPRECATED.md
Normal file
2
src/scripts/js/es6/common/templates/DEPRECATED.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
This module is used to render nodes/users dynamically. It was written before we introduced vue.js into the project.
|
||||||
|
Current best practice is to use vue for this type of work.
|
@@ -2,25 +2,50 @@ import { ComponentCreatorInterface } from './ComponentCreatorInterface'
|
|||||||
|
|
||||||
const REGISTERED_CREATORS = []
|
const REGISTERED_CREATORS = []
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a jQuery renderable element from a mongo document using registered creators.
|
||||||
|
* @deprecated use vue instead
|
||||||
|
*/
|
||||||
export class Component extends ComponentCreatorInterface {
|
export class Component extends ComponentCreatorInterface {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Object} doc
|
||||||
|
* @returns {$element}
|
||||||
|
*/
|
||||||
static create$listItem(doc) {
|
static create$listItem(doc) {
|
||||||
let creator = Component.getCreator(doc);
|
let creator = Component.getCreator(doc);
|
||||||
return creator.create$listItem(doc);
|
return creator.create$listItem(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} doc
|
||||||
|
* @returns {$element}
|
||||||
|
*/
|
||||||
static create$item(doc) {
|
static create$item(doc) {
|
||||||
let creator = Component.getCreator(doc);
|
let creator = Component.getCreator(doc);
|
||||||
return creator.create$item(doc);
|
return creator.create$item(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} candidate
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
static canCreate(candidate) {
|
static canCreate(candidate) {
|
||||||
return !!Component.getCreator(candidate);
|
return !!Component.getCreator(candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register component creator to handle a node type
|
||||||
|
* @param {ComponentCreatorInterface} creator
|
||||||
|
*/
|
||||||
static regiseterCreator(creator) {
|
static regiseterCreator(creator) {
|
||||||
REGISTERED_CREATORS.push(creator);
|
REGISTERED_CREATORS.push(creator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} doc
|
||||||
|
* @returns {ComponentCreatorInterface}
|
||||||
|
*/
|
||||||
static getCreator(doc) {
|
static getCreator(doc) {
|
||||||
if (doc) {
|
if (doc) {
|
||||||
for (let candidate of REGISTERED_CREATORS) {
|
for (let candidate of REGISTERED_CREATORS) {
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* @deprecated use vue instead
|
||||||
|
*/
|
||||||
export class ComponentCreatorInterface {
|
export class ComponentCreatorInterface {
|
||||||
/**
|
/**
|
||||||
* @param {JSON} doc
|
* Create a $element to render document in a list
|
||||||
|
* @param {Object} doc
|
||||||
* @returns {$element}
|
* @returns {$element}
|
||||||
*/
|
*/
|
||||||
static create$listItem(doc) {
|
static create$listItem(doc) {
|
||||||
@@ -8,8 +12,8 @@ export class ComponentCreatorInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Create a $element to render the full doc
|
||||||
* @param {JSON} doc
|
* @param {Object} doc
|
||||||
* @returns {$element}
|
* @returns {$element}
|
||||||
*/
|
*/
|
||||||
static create$item(doc) {
|
static create$item(doc) {
|
||||||
@@ -17,8 +21,7 @@ export class ComponentCreatorInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param {Object} candidate
|
||||||
* @param {JSON} candidate
|
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
static canCreate(candidate) {
|
static canCreate(candidate) {
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
import { NodesBase } from "./NodesBase";
|
import { NodesBase } from "./NodesBase";
|
||||||
import { thenLoadVideoProgress } from '../utils';
|
import { thenLoadVideoProgress } from '../utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create $element from a node of type asset
|
||||||
|
* @deprecated use vue instead
|
||||||
|
*/
|
||||||
export class Assets extends NodesBase{
|
export class Assets extends NodesBase{
|
||||||
static create$listItem(node) {
|
static create$listItem(node) {
|
||||||
var markIfPublic = true;
|
var markIfPublic = true;
|
||||||
|
@@ -3,6 +3,10 @@ import { ComponentCreatorInterface } from '../component/ComponentCreatorInterfac
|
|||||||
|
|
||||||
let CREATE_NODE_ITEM_MAP = {}
|
let CREATE_NODE_ITEM_MAP = {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create $element from node object
|
||||||
|
* @deprecated use vue instead
|
||||||
|
*/
|
||||||
export class Nodes extends ComponentCreatorInterface {
|
export class Nodes extends ComponentCreatorInterface {
|
||||||
/**
|
/**
|
||||||
* Creates a small list item out of a node document
|
* Creates a small list item out of a node document
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
import { prettyDate } from '../../utils/prettydate';
|
import { prettyDate } from '../../utils/prettydate';
|
||||||
import { ComponentCreatorInterface } from '../component/ComponentCreatorInterface'
|
import { ComponentCreatorInterface } from '../component/ComponentCreatorInterface'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use vue instead
|
||||||
|
*/
|
||||||
export class NodesBase extends ComponentCreatorInterface {
|
export class NodesBase extends ComponentCreatorInterface {
|
||||||
static create$listItem(node) {
|
static create$listItem(node) {
|
||||||
let nid = (node._id || node.objectID); // To support both mongo and elastic nodes
|
let nid = (node._id || node.objectID); // To support both mongo and elastic nodes
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
import { NodesBase } from "./NodesBase";
|
import { NodesBase } from "./NodesBase";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create $element from a node of type post
|
||||||
|
* @deprecated use vue instead
|
||||||
|
*/
|
||||||
export class Posts extends NodesBase {
|
export class Posts extends NodesBase {
|
||||||
static create$item(post) {
|
static create$item(post) {
|
||||||
let content = [];
|
let content = [];
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
import { ComponentCreatorInterface } from '../component/ComponentCreatorInterface'
|
import { ComponentCreatorInterface } from '../component/ComponentCreatorInterface'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create $elements from user objects
|
||||||
|
* @deprecated use vue instead
|
||||||
|
*/
|
||||||
export class Users extends ComponentCreatorInterface {
|
export class Users extends ComponentCreatorInterface {
|
||||||
static create$listItem(userDoc) {
|
static create$listItem(userDoc) {
|
||||||
let roles = userDoc.roles || [];
|
let roles = userDoc.roles || [];
|
||||||
|
Reference in New Issue
Block a user