deserver
    Preparing search index...

    Class TableEditor

    The class handling inline edit in a table

    The table can consist of a heading using .... The tr with data that can be edited should have contenteditable set and have data-field and data-value set with what field to update in data-field and loaded value in data-value. The td should contain the value that can be edited. A optional tr at the end can contain add new record and will then be ignored by the edit table methods

    Hierarchy (View Summary)

    Index
    bs: any = null
    errorid: string = "error"
    errorModal: any = null
    errortoconsole: boolean = true
    errortoelement: boolean = true
    gtversion: string = '1.0.7'
    primarykey: string | null = null
    ptversion: string = '1.6.1'
    sc: ServerConnect | null = null
    shouldfirechange: boolean = false
    teversion: string = '1.0.2'
    tname: string | null = null
    • Append children created by html code to the end of the selected element

      Parameters

      • elmid: ElementDef

        a existing element or a string that will find a element by id

      • code: string

        html code for creating new elements

      Returns HTMLElement | null

      the first of the created elements or undefined if none created

    • Change the color of the button by first remove all btn- + primary, danger, warning, success and info classes then add the new class or classes and change the text if you want as well

      Parameters

      • elmid: ElementDef

        buttonid or button to change

      • toremove: string | string[] | undefined

        array classes or a single class string to remove extra

      • toadd: string | string[]

        array classes or a single class string to add

      • Optionaltext: string

        to be added to button instead of the one already there if parameter used

      Returns void

    • Clear the error element defined by errorid if active defined by errortoelement

      Returns void

    • Create new element from html code

      Parameters

      • code: string

        html code

      Returns HTMLCollection | null

      elements created from the html

    • Create a checkbox with a changable class set that can be used for event that will be used for select and deselect single or all depening on the value set

      function needed to be implemented is onchangecheckbox(event)

      Parameters

      • path: string
      • Optionalvalue: string

        if not set use path as value

      Returns string

    • Do a DELETE request to the url and return the json object

      Parameters

      • url: string

        an url that is allowed to use

      Returns Promise<{}>

      a real object from call to server or a {result: 'error', error: message}

    • Do a GET request to the url and return the json object

      Parameters

      • url: string

        an url that is allowed to use

      Returns Promise<{}>

      a real object from call to server or a {result: 'error', error: message}

    • Do a POST request to the url and return the json object

      Parameters

      • url: string

        an url that is allowed to use

      • indata: {}

        a object that will be stringified to send

      Returns Promise<{}>

      a real object from call to server or a {result: 'error', error: message}

    • Do a PUT request to the url and return the json object

      Parameters

      • url: string

        an url that is allowed to use

      • indata: {}

        a object that will be stringified to send

      Returns Promise<{}>

      a real object from call to server or a {result: 'error', error: message}

    • Find one HtlmElement

      Parameters

      • elmid: ElementDef

        a existing element or a string that will find a element by id

      • Optionalselector: string

        uses to find a element inside the element found by elmid

      Returns HTMLElement | null

      HtmlElement or null

    • Add or remove color classed on an element. Used to change colors to elements that have a prefix. Ex. btn-danger or text-success The prefix will be added to any classes given if no - in class name so you can use warning instead of btn-warning on a button

      By default primary, danger, warning, success and info is always removed before any add

      Parameters

      • elmid: ElementDef

        element id or the element to change

      • what: string

        A prefix to use for the classes like btn-

      • toremove: string | string[] | undefined

        array of classes or single class to remove or undefined if not used, if no - in name prefix will be added

      • toadd: string | string[]

        array of classes or single class to add or undefined if not used, if no - in name prefix will be added

      • Optionaltext: string

        to be added to button instead of the one already there if parameter used

      Returns void

    • Get 0 or more elements from selector(s) or element and selector

      Parameters

      • sel1: ElementDef

        existing element to be queried for children or a selector for selecting elemenets

      • Optionalsel2: string

      Returns NodeList | null

      list of Elements or null

    • Find attribute on element or on the first child that have this attribute and return the value

      Parameters

      • elid: ElementDef

        an existing element or a string that will find a element by id

      • attname: string

        name of the attribure to find

      Returns string | null

      attribute or null

    • Parameters

      • elmid: ElementDef

        element id or the element to start from

      • localname: string

        a name of html type in lower case

      Returns [HTMLElement | null, number]

      array of two elements where the first is the element matching the localname type or null and the second how many levels up from the start did we have to go

      function tablecellonclick(event){
      const [td, level] = this.findfirstparentoftype(event.target, 'td');
      if (td){
      // ... do something with table cell
      }
      }

      will find first td up in tree from the event.taget calling it

    • Check for attribute on element or children and return the first element having the attributre defined

      Parameters

      • elid: ElementDef

        an existing element or a string that will find a element by id

      • attname: string

        name of the attribure to find

      Returns HTMLElement | null

      element with attributre defined or null

    • Return a attribute value if it exists

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • attr: string

        attribute name

      Returns string

      attribute value or blank string

    • Return a attribute value if it exists

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • attr: string

        attribute name

      • nullonnotfound: true

        if set to true a null will be returned for not found

      Returns string | null

      attribute value or blank or null depending on nullonnotfound

    • Parameters

      Returns number

    • Get the td and values given a tr element

      Parameters

      • trel: ElementDef

        the tr to search for the field data

      • fname: string

        the field name to lookup

      Returns [ElementDef | null, string | null, string | null]

      return the element for given field name and data-value and content as array with 3 values

    • Hide a element by adding d-none class

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      Returns HTMLElement | null

      the element or null

    • Get inner htlm to or from a element

      Parameters

      • elmid: ElementDef

        a existing element or a string that will find a element by id

      Returns string | null

      the inner htlm of the element or null if element not found

    • Set inner htlm to an element

      Parameters

      • elmid: ElementDef

        a existing element or a string that will find a element by id

      • code: string

        if given a string, it will be set to the element

      Returns HTMLElement | null

      null if element not found or the element if code set

    • Test if a instance is a real array and not object or null

      Parameters

      • x: any

        to test

      Returns boolean

      true if real array

    • Give to strings in the form of semantic versioning and tell if the first is newer than the second Support any type version as long as they are seperated by the same number of . Ex. 0.1.0 and 0.1.1 gives false Ex. 9.0.0.2992 and 9.0.0.2990 gives true Ex. 9.1.0.0 and 9.0.0.2990 gives true as well

      Parameters

      • latest: string

        version to check

      • installed: string

        version to check against

      Returns boolean

      true or false

    • Test if a instance is a real object and not array or null

      Parameters

      • x: any

        to test

      Returns boolean

      true if real object

    • Swap and table rows and update data for given sort field in both records on server

      Parameters

      • event: Event
      • direction: "up" | "down"

        up or down

      • tname: string

        table name to update in

      • queryfield: string

        field to use for query under update

      • datafield: string

        field to update with value from swapped row

      Returns Promise<RecordSaveResults>

    • Parameters

      • e: KeyboardEvent

      Returns void

    • Call a method when element selected is changed

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • fn: EventListener

        a method in the class extended on this class

      Returns void

    • Call a method when element selected is clicked

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • fn: EventListener

        a method in the class extended on this class

      Returns void

    • Call a method when element get the named event. This method if for handleing all events that not are so commonly used that they have got their own method like onclickme

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • eventname: string

        the name for the event to register ex input, focusin, focusout

      • fn: EventListener

        a method in the class extended on this class

      Returns void

    • Call this function when document have finished loading

      Parameters

      • fn: EventListener | (() => void)

        a function to run

      Returns void

    • Remove children from the back of thil element till there is only the amount of to left

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • Optionalto: number

        hove many children to be left, default is 0 if not set

      Returns void

    • Add a class to all selected elements

      Parameters

      • selector: string

        a selector that will match elements in the DOM

      • cname: string

        class name to add

      Returns void

    • Remove class from all selected elements

      Parameters

      • selector: string

        a selector that will match elements in the DOM

      • cname: string

        class name to remove

      Returns void

    • Send error to console and error element if defined To error element is defined by errorid and errortoelement To console is defined by errortoconsole

      Parameters

      • result: any

        the result from call to deserver api or a string

      Returns void

    • Set a attribute value on a element or if value is null, remove it

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • attr: string

        attribute name

      • val: string

        a string value to set or null if you want to remove the attribute

      Returns HTMLElement | null

      element if found and attribute set or null if element not found or remove failed

    • Used by showerror for displaying a error dialog and to avoid a lot of extra code in the budlels we prefer to set it dynamically after creation of guitools. What is used is for now is bootstap.Modal

      Parameters

      • bootstrap: any

        the bootstrap element set in window.bootstrap when loading bootrap.js in browser

      Returns void

    • Parameters

      • el: HTMLElement
      • caretpos: string | number

      Returns void

    • Returns void

    • For make a part of the page adjust to the resizing of the app

      Parameters

      • elmid: ElementDef

        element id or the element to resize

      • Optionaladjust: number

        default if 40 px at the bottom is left, you can use a different number by adding it here

      Returns void

    • Set the values on td given a tr element and what field

      Parameters

      • trel: ElementDef

        the tr to search for the field data

      • fname: string

        the field name to lookup

      • val: string

        the value to det in td and data-value attribute

      Returns HTMLElement | null

      return the element for given field name or null if not found

    • Show a element by remove d-none class

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      Returns HTMLElement | null

      the element or null

    • Show the error modal that should be defined in the html a id="ErrorModal" Needs to be async to be able to dynamically load bootstrap if not already done

      Parameters

      • title: string

        The title on top of error

      • msg: string

        The error message in dialog, can be text or html

      • Optionaladdcancelchain: boolean

        show the chain cancel button or not

      Returns Promise<void>

    • Parameters

      • el: HTMLElement
      • direction: string
      • caretpos: string | number

      Returns HTMLElement | null

    • Parameters

      • el: HTMLElement

      Returns HTMLElement | null

    • Parameters

      • el: HTMLElement

      Returns HTMLElement | null

    • Change the color of the text by first remove all text- + primary, danger, warning, success and info classes then add the new class or classes and change the text if you want as well

      Parameters

      • elmid: ElementDef

        element id or the element to change

      • toremove: string | string[] | undefined

        array classes or a single class string to remove extra

      • toadd: string | string[]

        array classes or a single class string to add

      • Optionaltext: string

        to be added to button instead of the one already there if parameter used

      Returns void

    • Check for change and update a field in a database table from a focus out event in a table with data-value with old value, data-field with the field changed and the new value in td

      Parameters

      • event: Event

        the focus out event

      • tname: string

        table name to update with new value

      • primarykey: string

        The primary key to lookup record to update by finding it in current tr with a data-field= with this value, the value in data-value will be used for the key

      Returns Promise<RecordSaveResults | null>

      RecordSaveResults if all requirements where meet and null if not. A successful updata should return jdata.result == 'ok'

    • Get value from element

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      Returns string | boolean | null

      return the value of element as string or boolean if the element exists and null if not

    • Set value in element

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • val: string | boolean

        this is the value to set

      Returns null | undefined

      it will return undefined if a value is set and null if element do not exist