Giter Club home page Giter Club logo

jsoms's People

Contributors

dependabot[bot] avatar spl1nes avatar

Stargazers

 avatar

Watchers

 avatar

jsoms's Issues

Fix direct element usage

Code like the following is bad since it will cause exceptions/errors:

document.getElementById(key).checked

Make sure to check that the element actually exists.

[ActionManager] Double request submit

Currently requests generated by the action manager don't have a multiple send prevention mechanism. This feature is implemented for forms and should be implemented here as well.

Preferably this should be done in the message.request action itself.

[UriFactory] Replace current url

Instead of generating a new url it should be possible to replace the current url partially.

This would require to parse something like {!self}.

Adjust to meet phpOMS methods

Instead of making it behave differently from the phpOMS they should behave the same way and have similar if not the same methods.

[data-href] Implement

Currently the data-href is only implemented for tables but this would be useful for all elements?!

[GeneralUI] Create

Create general UI behavior class. Some general behavior that is not related to tables, forms etc. should be handled in this class.

E.g. data-href object from issue #28.

[FormView] Bind elements in view

Currently many elements are bound in a more abstract class e.g. Form and not in the View e.g. FormView. Maybe it makes more sense to bind the functionality always in the View and not in the managing class.

Same goes for Tables, Media module etc. The editor is doing the binding in the Editor class and not in the controller.

Generalization of action injection

The button injection could/should be pulled up and a general action handler should be specified. This way not only button actions will be able to trigger actions but also other events:

  1. Link click
  2. Scrolling (which I personnaly don't like)
  3. Keystrokes in input fields
  4. Mouse clicks in general

Merge external form elements

Form elements, that are not inside of the form should be merged with the ones that are. For that a merge function should be implemented in the oLib.

Another alternative is to create your own selector for querySelector and querySelectorAll which could return a joined list/array.

Potential layout for selecting node that matches two selectors (only one result):

jsOMS.querySelector('.selector1, selector[type=2]', baseNode(optional));

Potential layout for selecting nodes that match two selectors (list/array of results):

jsOMS.querySelectorAll('.selector1, selector[type=2]', baseNode(optional));

[ActionManager] Sync/Async events

Events so fare can be created sync and async depending on the implementation. It would be better to make it sync/async depending on a option flag.

Set max min calculation function

Right now the max min calculation for the axis max/min is always calculated the same way. It would be smarter to set a default calculation but allow a dynamic calculation via callbacks.

Pull out charts

The charts objects are very unorganized and many methods could get cleaned up by simply pulling out functionality.

Stacked chart points

The dataset should be optimized in the chart object not beforehand. For the stacked chart to work it always needs to know the y position of the previous dataset. At the same time the markers are not positioned correctly yet!

Create advanced Masonry

Create Masonry like ordering but with dynamic width/height elements either floating or flexbox.

Could be very complex especially by considering smaller resolution as special case and resizable windows.

Redirect swipe to keyboard input

Swipe should be redirected to arrow keys.

Redirect swipe after validation to the corresponding keyobard input.

This way the behaviour has to be implemented only once.

[Table] Add basic table handling (no db and pagination)

For simple tables a short table handling should be implemented. This should only be viable for none-paginated tables.

Long tables which are paginated and result from db queries need to have the same features but should not be part of this first basic implementation.

Draft Solution

Make sure to integrate this into the UIManager.js. Additional steps for implementing the code below are the addition of click events on icons in the table which trigger the sorting and filtering.

The filtering should also result from user inpunt (maybe similarly to excel table filtering?).

construct(id)
{
    this.id = id;
}

sortBy(column, order = 'ASC')
{
    let table = document.getElementById(this.id),
        row1 = null,
        row2 = null,
        swap = false;

    const length = table.rows.length;

    do {
        for (let i = 1; i < length - 1; ++i) {
            swap = false;

            row1 = table.rows[i].getElementsByTagName('TD')[column];
            row2 = table.rows[i + 1].getElementsByTagName('TD')[column];

            if (this.checkOrder()) {
                swap = true;
                break;
            }
        }

        if (swap) {
            table.rows[i].parentNode.insertBefore(table.rows[i + 1], table.rows[i]);
        }
    } while(swap)
}

checkOrder(row1, row2, order)
{
    switch (order) {
        case 'ASC':
            return row1['data-value'].toLowerCase() > row2['data-value'].toLowerCase();
        case 'DESC':
            return row1['data-value'].toLowerCase() < row2['data-value'].toLowerCase()
    };
}

filterBy(column, filter)
{
	let table = document.getElementById(this.id);

    const length = table.rows.length;

    for (let i = 0; i < length - 1; ++i) {
        if (table.rows[i]['data-value'].match(filter)) {
            // todo: remove class hidden - see basic oLib.js features
        } else {
            // todo: add class hidden - see basic oLib.js features
        }
    }
}

[Form] Prevent double submit

Currently it is possible to accidentally submit a form multiple times. The formview should have some internal timer to prevent this (e.g. no submit within 0.3 sec).

This could be a problem for forms that don't submit data but request data. Maybe this should only be done for none-GET forms.

[FormView] Duplicated data elements

When submitting a form the view collects data from all form elements and from form elements which have the form= set to the same id. The problem with this is that a form element which is part of the form and has set the form= will be part of the list two times. This needs to be fixed.

Solution:
Before returning the element array it should be traversed and filtered for duplicates.

Replace current page content with api response content

Instead of loading the whole page again maybe use JS to only load specific content elements and replace them (main content) like youtube etc.

Maybe even make this smart enough to fully load a page and then only replace the html that is different from the current page? This way the api doesn't have to respond with very specific content elements. At the same time specific content elements could be served way faster! Don't know which is better for now?!

[EventManager] Reset events

Currently if all conditions are met for an event it will trigger. If the event is persistent (doesn't get removed after triggering) it will from then on always get triggered even if only one subcondition is triggering. This can be OK but there could be situation where the event should be persistent but all conditions for triggering the event should be reset.

Implement an option to reset the event after triggering it. This will only be used if the event is persistent.

FormManager button injection

Implement button injection for forms. Buttons need to be implemented with type="button" and formaction="...". The formaction attribute has to contain the request uri which will always get triggerd as post request.

This will be useful in order to request e.g. ui elements from the api that are not loaded.

Create message and action pool

Messages and actions should be stored in one place. Messages and actions should be used for both respectively since they can be designed similarly.

First example would be the request/redirect callback, which looks the same for both. On the other hand they could look and work differently in the future which means they need to be handled separately.

[ActionManager] Template actions cannot be overwritten

Templates by nature get added and removed from a page (often in order to reuse existing html to minimize the html load). The problem with templates is that they need to register in the ActionManager.js. A listener currently is only registered once per id.

Since templates often keep the same id for some elements this results in a problem because the new template will not register a new listener.

Possible solutions:

  1. Force unique ids for templates during setup (pro: fast and easy initial solution, con: action event pollution not solved)
  2. Whenever a dom element with action elements is removed, also unregister the listeners (pro: clean solution, con: difficult to implement)

Solution 2 will be implemented. Maybe this can be performed in the dom removing action events or a dom listener would be required to listen for these dom elements.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.