Evolutility-UI-jQuery

使用jQuery和Backbone(用于REST或localStorage)的CRUD的模型驱动Web UI。【Model-driven Web UI for CRUD using jQuery and Backbone (for REST or localStorage).】

Github stars Tracking Chart

Evolutility-UI-jQuery

Evolutility-UI-jQuery提供了一组通用的Backbone Views来浏览、编辑、过滤、导出和绘制Backbone模型和不同结构的集合。 有了它,您可以通过配置元数据而不是手动编码模板,Javascript和CSS来配置视图来制作Web应用程序。

默认情况下,Evolutility-UI-jQuery使用浏览器本地存储来存储数据(因为没有服务器或数据库来设置,因此更容易进行演示)。

Evolutility-Server-Node 使用Node.js,Express和Postgres提供了一个匹配的RESTful API。

演示应用

使用Evolutility制作示例单页应用程序: 待办事项列表地址簿酒窖图形小说

安装

下载克隆 Evolutility-UI-jQuery来自GitHub。

 #要获得最新的稳定版本,请使用命令行中的git。
git clone https://github.com/evoluteur/evolutility-ui-jquery

默认情况下,Evolutility-UI-jQuery被配置为使用localStorage来存储数据。使其与REST API协同工作:

  • 在“config.js”文件
  • 中使用“url”属性指定REST根端点
  • 运行Grunt(重建evolutility-ui-jquery.js(或evolutility-ui-jquery.min.js),
  • 将应用移至网路伺服器。

对于匹配的RESTful API,您还需要设置 Evolutility-Server-Node

浏览

Evolutility-UI-jQuery的视图有一个Backbone模型(用于定义数据)和一个UI模型(用于定义UI以显示数据并与之交互)。

Backbone模型和集合的所有视图都以简单的声明方式共享单个UI模型,该视图以跨视图定义所有UI元素。

Evolutility-UI-jQuery提供了3种类型的视图

API的大部分(方法,选项和事件)对所有视图都是通用的。有些视图还有其他API。

一个模型的视图

浏览

显示所有要查看的字段(只读)。字段分组在面板和标签中。

 var vw = new Evol.ViewOne.Browse({
            el: myElement,
            uiModel: myUIModel,
            model: myModel
        });

代码:/js/view-one/one-browse.js

修改

此视图显示版本的所有字段以创建或更新模型。 它基于UI模型自动执行验证,并支持Master-Details模式(嵌套集合)。 字段分组在面板和标签中。

 var vw = new Evol.ViewOne.Edit({
            el: myElement,
            uiModel: myUIModel,
            model: myModel
        });

代码:/js/view-one/one-edit.js

迷你(Mini)

用于快速编辑。仅显示重要的字段(必填或显示为网格中的列)。字段分组在一个面板中。

 var vw = new Evol.ViewOne.Mini({
            el: myElement,
            uiModel: myUIModel,
            model: myModel
        });

代码:/js/view-one/one-mini.js

JSON

数据的JSON表示。

 var vw = new Evol.ViewOne.JSON({
            el: myElement,
            uiModel: myUIModel,
            model: myModel
        });

代码:/js/view-one/one-json.js

多个模型集合的视图

列表

通过分页给出一个集合的表格视图。

 var vw = new Evol.ViewMany.List({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

代码:/js/view-many/many-list.js

卡片

将记录并排显示为卡片。

 var vw = new Evol.ViewMany.Cards({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

代码:/js/view-many/many-cards.js

气泡

“气泡”视图将数据显示为带有控件的气泡,以便对它们进行分组并设置它们的颜色和大小(此视图使用D3.js)。 鼠标悬停显示项目卡片视图的工具提示。

 var vw = new Evol.ViewMany.Bubbles({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

代码:/js/view-many/many-bubbles.js /js/view-many/many-bubbles-d3.js

图表

绘制有关集合的图表。

 var vw = new Evol.ViewMany.Charts({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

代码:/js/view-many/many-charts.js

Actions视图

过滤

视图用于构建结构化查询以过滤集合。

 var vw = new Evol.ViewAction.Filter({
            el: myElement,
            uiModel: myUIModel
        });

代码:/js/view-action/action-filter.js

导出

查看定义导出选项并以不同数据格式(CSV,TAB,HTML,XML,SQL和JSON)预览导出集合。

 var vw = new Evol.ViewAction.Export({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

代码:/js/view-action/action-export.js

导入

从CSV或JSON文件导入数据的视图。这是一项正在进行的工作。

 var vw = new Evol.ViewAction.Import({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

代码:/js/view-action/action-import.js

UI-model

视图未在模板中定义,但使用词汇表配置了UI模型,用“field”,“panel”和“tab”等词语,而不是“input”和“div”来描述UI元素。

以下是用于配置所有视图的UI模型“Graphic Novels”应用程序演示

立即尝试:下载Evolutility-UI-jQuery ,修改演示UI模型(在“模型”子目录中),通过添加和修改字段和面板并查看演示应用程序成为您的应用程序。

 var uiModels_comics = {
    id: 'comics',
    label: 'Graphic Novels',
    name: 'graphic novel serie',
    namePlural: 'graphic novel series',
    fnTitle: 'title',
    fnBadge: function(m){
        var hNb=m.get('haveNb'),
            sNb=m.get('serieNb');
        return (hNb==sNb)?hNb:hNb+'/'+sNb;
    },
    elements: [
        {
            type: 'panel', label: 'Serie', width: 70,
            elements: [
                {
                    id: 'title', attribute: 'title', type: 'text', 
                    label: 'Title', required: true, 
                    maxLength: 255,
                    width: 62, inMany: true
                },
                {
                    id: 'genre', attribute: 'genre', type: 'lov', 
                    label: 'Genre', width: 38, inMany: true,
                    list: [
                        {id: 1, text: 'Adventure'},
                        {id: 2, text: 'Fairy tale'},
                        {id: 3, text: 'Erotic'},
                        {id: 4, text: 'Fantastic'},
                        {id: 5, text: 'Heroic Fantasy'},
                        {id: 6, text: 'Historic'},
                        {id: 7, text: 'Humor'},
                        {id: 8, text: 'One of a kind'},
                        {id: 9, text: 'Youth'},
                        {id: 10, text: 'Thriller'},
                        {id: 11, text: 'Science-fiction'},
                        {id: 12, text: 'Super Heros'},
                        {id: 13, text: 'Western'} 
                    ]
                },
                {
                    id: 'authors', attribute: 'authors', type: 'text', 
                    label: 'Authors', width: 62, inMany: true
                },
                {
                    id: 'language', attribute: 'language', type: 'lov', 
                    label: 'Language', width: 38, inMany: false,
                    list: [
                        {id: 2, text: 'French', icon:'flag_fr.gif'},
                        {id: 1, text: 'American', icon:'flag_us.gif'}                    ]
                },
                {
                    id: 'serie_nb', attribute: 'serie_nb', type: 'integer', 
                    label: 'Albums', width: 15, inMany: false,
                    inCharts: false 
                },
                {
                    id: 'have_nb', attribute: 'have_nb', type: 'integer',
                    label: 'Owned', width: 15, inMany: false, 
                    inCharts:false 
                },
                {
                    id: 'have', attribute: 'have', type: 'text',
                    label: 'have', width: 32, inMany: false 
                },
                {
                    id: 'complete', attribute: 'complete', type: 'boolean',
                    label: 'Complete', width: 19, inMany: true, 
                    labelFalse:'Incomplete', labelTrue:'Complete'
                },
                {
                    id: 'finished', attribute: 'finished', type: 'boolean', 
                    label: 'Finished', width: 19, inMany: true,
                    labelTrue:'Finished', labelFalse:'Unfinished', css:'cBlue'
                },
                {
                    id:'amazon', type:'formula', 
                    label:'Amazon', width:100, css:'evol-ellipsis',
                    formula:function(m){
                        var urlData=m.get('title')+' '+m.get('authors'),
                        link=m.get('language')=='FR' ?
                            'http://www.amazon.fr/s/ref=sr_nr_n_1?keywords='
                            :'http://www.amazon.com/s/ref=nb_sb_noss?field-keywords=';
                        return '<a target="a" href="'+link+encodeURI(urlData)+'">'+
                            _.escape(urlData)+'</a>';
                    }
                },
                {
                    id: 'notes', attribute: 'notes', type: 'textmultiline', 
                    label: 'Notes', maxLength: 1000,
                    width: 100, height: 6, inMany: false
                }
            ]
        },
        {
            type: 'panel', label: 'Cover', width: 30,
            elements: [
                {
                    id: 'pix', attribute: 'pix', type: 'image',
                    label: 'Cover', width: 100, inMany: true
                }
            ]
        }
    ]
};

请参阅 UI模型文档了解可用的UI词汇表(结构UI模型或元模型)。

演示应用的UI模型: 待办事项列表地址簿酒窖图形小说

堆栈和依赖关系

Javascript,HTML5,CSS3, Backbone.js Underscore.js jQuery D3.js Bootstrap Bootstrap-datepicker Select2 Toastr

注意:为了方便起见,所有依赖关系都在一个文件“dependencies.min.js”中缩小。依赖关系列表在“Gruntfile.js”中指定。

文档

文档的(开头)正在进行中:ui-models views

Evolutility的其他实现

Evolutility-UI-React -- 使用React的CRUD的模型驱动Web UI。

Evolutility-Server-Node -- 适用于CRUD的RESTful Micro-ORM等等,用Javascript编写,使用Node .js,Express和Postgres。

Evolutility -- 使用ASP.net和Microsoft SQL-Server进行繁重的轻量级CRUD框架。

许可证

版权所有(c)2017 Olivier Giulieri

Evolutility-UI-jQuery在 MIT许可下发布。

Overview

Name With Ownerevoluteur/evolutility-ui-jquery
Primary LanguageJavaScript
Program languageHTML (Language Count: 3)
PlatformWeb browsers
License:MIT License
Release Count33
Last Release Name1.2.4 (Posted on )
First Release Name0.0.1 (Posted on )
Created At2012-12-13 07:34:21
Pushed At2024-03-17 08:48:23
Last Commit At
Stargazers Count178
Watchers Count37
Fork Count55
Commits Count897
Has Issues Enabled
Issues Count20
Issue Open Count5
Pull Requests Count1
Pull Requests Open Count0
Pull Requests Close Count1
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Evolutility-UI-jQuery · GitHub license npm version

Evolutility-UI-jQuery provides a set of generic Backbone Views to browse, edit, filter, export and chart Backbone models and collections of different structures.
With it you can make web applications by configuring views with metadata instead of hand-coding templates, Javascript and CSS.

By default Evolutility-UI-jQuery uses your browser local storage to store data (easier for demos because there is no server or database to setup).

Evolutility-Server-Node provides a matching RESTful API using Node.js, Express, and Postgres.

Demo apps

Sample Single Page Apps made with Evolutility:
To Do list,
AddressBook,
Wine Cellar,
Graphic Novels.

Installation

Download or clone Evolutility-UI-jQuery from GitHub.

# To get the latest stable version, use git from the command line.
git clone https://github.com/evoluteur/evolutility-ui-jquery

or use the npm package:

# To get the latest stable version, use npm from the command line.
npm install evolutility-ui-jquery

By default, Evolutility-UI-jQuery is configured use localStorage for storing data. To make it work with a REST API:

  • specify the REST root endpoint using the "url" attribute in the "config.js" file,
  • run Grunt (to rebuild evolutility-ui-jquery.js (or evolutility-ui-jquery.min.js),
  • move the app to a web server.
# To rebuild the project
cd evolutility-ui-jquery
bower install
grunt

For the matching RESTful API you will also need to setup Evolutility-Server-Node.

Views

Evolutility-UI-jQuery's views have a Backbone model (to define the data) and also a UI-model (to define the UI to display the data and interact with it).

All views for a Backbone model and collection share a single UI-Model which defines of all UI elements across views in a simple declarative way.

Evolutility-UI-jQuery provides 3 types of views

A large part of the API (methods, options and events) is common to all views. Some views have additional API.

Views for One model

Browse

Shows all fields for viewing (read only). Fields are grouped in panels and tabs.

Browse

var vw = new Evol.ViewOne.Browse({
            el: myElement,
            uiModel: myUIModel,
            model: myModel
        });

Code: /js/view-one/one-browse.js

Edit

This view shows all fields for edition to create or update models.
It automatically performs validation based on the UI-model and supports the Master-Details pattern (nested collections).
Fields are grouped in panels and tabs.

Edit

var vw = new Evol.ViewOne.Edit({
            el: myElement,
            uiModel: myUIModel,
            model: myModel
        });

Code: /js/view-one/one-edit.js

Mini

Used for quick edits. Only shows important fields (required or showing as a column in grids). Fields are grouped in a single panel.

Mini

var vw = new Evol.ViewOne.Mini({
            el: myElement,
            uiModel: myUIModel,
            model: myModel
        });

Code: /js/view-one/one-mini.js

JSON

JSON representation of the data.

JSON

var vw = new Evol.ViewOne.JSON({
            el: myElement,
            uiModel: myUIModel,
            model: myModel
        });

Code: /js/view-one/one-json.js

Views for a collection of Many models

List

Gives a tabular view of a collection with paging.

List

var vw = new Evol.ViewMany.List({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

Code: /js/view-many/many-list.js

Cards

Shows records side by side as cards.

Cards

var vw = new Evol.ViewMany.Cards({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

Code: /js/view-many/many-cards.js

Bubbles

The "Bubbles" view displays the data as bubbles with controls to group them and set their color and size (this view uses D3.js).
A tooltip with the Card view of the item show on mouse over.

Bubbles

var vw = new Evol.ViewMany.Bubbles({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

Code: /js/view-many/many-bubbles.js and /js/view-many/many-bubbles-d3.js

Charts

Draws charts about the collection.

Charts

var vw = new Evol.ViewMany.Charts({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

Code: /js/view-many/many-charts.js

Views for Actions

Backbone Views for actions on a collection or a model.

Filter

View used to build a structured query to filter a collection.

Filter

var vw = new Evol.ViewAction.Filter({
            el: myElement,
            uiModel: myUIModel
        });

Code: /js/view-action/action-filter.js

Export

View to define export options and preview the collection export in different data formats (CSV, TAB, HTML, XML, SQL and JSON).

Export

var vw = new Evol.ViewAction.Export({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

Code: /js/view-action/action-export.js

Import

View to import data from a CSVor JSON file. It is a work in progress.

var vw = new Evol.ViewAction.Import({
            el: myElement,
            uiModel: myUIModel,
            collection: myCollection
        });

Code: /js/view-action/action-import.js

UI-model

Views are not defined in templates but configured with a UI-model using a vocabulary with words like "field", "panel" and "tab" rather than "input" and "div" to describe UI elements.

Here is the UI-model used to configure all views for the "Graphic Novels" app demo:

Try it now: Download Evolutility-UI-jQuery, make modification to the demo UI-models (in the "model" sub-directory) by adding and modifying fields and panels and see the demo apps become your apps.


var uiModels_comics = {
    id: 'comics',
    label: 'Graphic Novels',
    name: 'graphic novel serie',
    namePlural: 'graphic novel series',
    fnTitle: 'title',
    fnBadge: function(m){
        var hNb=m.get('haveNb'),
            sNb=m.get('serieNb');
        return (hNb==sNb)?hNb:hNb+'/'+sNb;
    },
    elements: [
        {
            type: 'panel', label: 'Serie', width: 70,
            elements: [
                {
                    id: 'title', attribute: 'title', type: 'text', 
                    label: 'Title', required: true, 
                    maxLength: 255,
                    width: 62, inMany: true
                },
                {
                    id: 'genre', attribute: 'genre', type: 'lov', 
                    label: 'Genre', width: 38, inMany: true,
                    list: [
                        {id: 1, text: 'Adventure'},
                        {id: 2, text: 'Fairy tale'},
                        {id: 3, text: 'Erotic'},
                        {id: 4, text: 'Fantastic'},
                        {id: 5, text: 'Heroic Fantasy'},
                        {id: 6, text: 'Historic'},
                        {id: 7, text: 'Humor'},
                        {id: 8, text: 'One of a kind'},
                        {id: 9, text: 'Youth'},
                        {id: 10, text: 'Thriller'},
                        {id: 11, text: 'Science-fiction'},
                        {id: 12, text: 'Super Heros'},
                        {id: 13, text: 'Western'} 
                    ]
                },
                {
                    id: 'authors', attribute: 'authors', type: 'text', 
                    label: 'Authors', width: 62, inMany: true
                },
                {
                    id: 'language', attribute: 'language', type: 'lov', 
                    label: 'Language', width: 38, inMany: false,
                    list: [
                        {id: 2, text: 'French', icon:'flag_fr.gif'},
                        {id: 1, text: 'American', icon:'flag_us.gif'}                    ]
                },
                {
                    id: 'serie_nb', attribute: 'serie_nb', type: 'integer', 
                    label: 'Albums', width: 15, inMany: false,
                    inCharts: false 
                },
                {
                    id: 'have_nb', attribute: 'have_nb', type: 'integer',
                    label: 'Owned', width: 15, inMany: false, 
                    inCharts:false 
                },
                {
                    id: 'have', attribute: 'have', type: 'text',
                    label: 'have', width: 32, inMany: false 
                },
                {
                    id: 'complete', attribute: 'complete', type: 'boolean',
                    label: 'Complete', width: 19, inMany: true, 
                    labelFalse:'Incomplete', labelTrue:'Complete'
                },
                {
                    id: 'finished', attribute: 'finished', type: 'boolean', 
                    label: 'Finished', width: 19, inMany: true,
                    labelTrue:'Finished', labelFalse:'Unfinished', css:'cBlue'
                },
                {
                    id:'amazon', type:'formula', 
                    label:'Amazon', width:100, css:'evol-ellipsis',
                    formula:function(m){
                        var urlData=m.get('title')+' '+m.get('authors'),
                        link=m.get('language')=='FR' ?
                            'http://www.amazon.fr/s/ref=sr_nr_n_1?keywords='
                            :'http://www.amazon.com/s/ref=nb_sb_noss?field-keywords=';
                        return '<a target="a" href="'+link+encodeURI(urlData)+'">'+
                            _.escape(urlData)+'</a>';
                    }
                },
                {
                    id: 'notes', attribute: 'notes', type: 'textmultiline', 
                    label: 'Notes', maxLength: 1000,
                    width: 100, height: 6, inMany: false
                }
            ]
        },
        {
            type: 'panel', label: 'Cover', width: 30,
            elements: [
                {
                    id: 'pix', attribute: 'pix', type: 'image',
                    label: 'Cover', width: 100, inMany: true
                }
            ]
        }
    ]
};

See UI-Model documentation for the UI vocabulary available (structure of UI-models or metamodel).

UI-Models for the demo apps:
To Do list,
AddressBook,
Wine Cellar,
Graphic Novels.

Stack and dependencies

Javascript, HTML5, CSS3,
Backbone.js,
Underscore.js,
jQuery,
D3.js,
Bootstrap,
Bootstrap-datepicker,
Select2,
Toastr.

Note: For convenience, all dependencies are minified together in a single file "dependencies.min.js". The dependencies list is specified in "Gruntfile.js".

The React alternative:
Evolutility-UI-React

Documentation

The (beginning of a) documentation is in progress: ui-models and views.

License

Copyright (c) 2020 Olivier Giulieri.

Evolutility-UI-jQuery is released under the MIT license.

To the top