Skip to content
Snippets Groups Projects
Select Git revision
  • f68f71f94d9f1be5143fe12dd572080090e63d8c
  • master default protected
  • 1.31
  • 4.34.1
  • 4.34.0
  • 4.33.1
  • 4.33.0
  • 4.32.2
  • 4.32.1
  • 4.32.0
  • 4.31.0
  • 4.30.1
  • 4.30.0
  • 4.29.1
  • 4.29.0
  • 4.28.0
  • 4.27.0
  • 4.26.0
  • 4.25.5
  • 4.25.4
  • 4.25.3
  • 4.25.2
  • 4.25.1
23 results

datasource.mjs

Blame
  • datasource.mjs 2.18 KiB
    /**
     * Copyright 2023 schukai GmbH
     * SPDX-License-Identifier: AGPL-3.0
     */
    
    import {
    	CustomElement,
    	assembleMethodSymbol,
    } from "../../dom/customelement.mjs";
    import { Datasource as DatasourceBase } from "../../data/datasource.mjs";
    import { instanceSymbol } from "../../constants.mjs";
    
    export { Datasource, dataSourceSymbol };
    
    /**
     * @private
     * @type {symbol}
     */
    const dataSourceSymbol = Symbol.for(
    	"@schukai/monster/components/datasource@@datasource",
    );
    
    /**
     * The Datasource component is a basic class for the datatable component.
     *
     * <img src="./images/datasource.png">
     *
     * Dependencies: the system uses functions of the [monsterjs](https://monsterjs.org/) library
     *
     * @startuml datasource.png
     * skinparam monochrome true
     * skinparam shadowing false
     * HTMLElement <|-- CustomElement
     * CustomElement <|-- Datasource
     * @enduml
     *
     * @copyright schukai GmbH
     * @memberOf Monster.Components.Datatable
     * @summary A abstract datasource
     */
    class Datasource extends CustomElement {
    	/**
    	 * the constructor of the class
    	 */
    	constructor() {
    		super();
    		this[dataSourceSymbol] = new DatasourceBase();
    	}
    
    	/**
    	 * This method is called by the `instanceof` operator.
    	 * @returns {symbol}
    	 */
    	static get [instanceSymbol]() {
    		return Symbol.for("@schukai/monster/components/datasource@@instance");
    	}
    
    	/**
    	 * To set the options via the html tag the attribute `data-monster-options` must be used.
    	 * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
    	 *
    	 * The individual configuration values can be found in the table.
    	 *
    	 * @property {Object} templates Template definitions
    	 * @property {string} templates.main Main template
    	 */
    	get defaults() {
    		return Object.assign({}, super.defaults, {});
    	}
    
    	/**
    	 *
    	 * @return {Monster.Components.Form.Form}
    	 */
    	[assembleMethodSymbol]() {
    		super[assembleMethodSymbol]();
    	}
    
    	/**
    	 * Get the data, without proxy
    	 * @returns {Object}
    	 */
    	get data() {
    		return this[dataSourceSymbol].get();
    	}
    
    	/**
    	 * set the data
    	 * @param {Object} data
    	 */
    	set data(data) {
    		this[dataSourceSymbol].set(data);
    	}
    
    	/**
    	 * Get the datasource
    	 * @returns {Monster.Data.Datasource}
    	 */
    	get datasource() {
    		return this[dataSourceSymbol];
    	}
    }