Skip to content

Commit

Permalink
refactory of dataTable for Angular Style
Browse files Browse the repository at this point in the history
  • Loading branch information
insinfo committed Jul 22, 2020
1 parent d80bd88 commit a6930a8
Show file tree
Hide file tree
Showing 15 changed files with 974 additions and 839 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ build/

# Directory created by dartdoc
doc/api/

.idea/
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,8 @@ and fix issues

# 1.1.0

- fix documentation and overall bugs
- fix documentation and overall bugs

# 1.2.3

- refactory of EssentialDataTableComponent and add news features
675 changes: 332 additions & 343 deletions example/.firebase/hosting.YnVpbGQ.cache

Large diffs are not rendered by default.

103 changes: 45 additions & 58 deletions example/lib/src/models/person.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,47 @@ class Person implements IDataTableRender, ISimpleSelectRender, TimelineRender {
String avatar;
bool enable;
String description;
DataTableRow dataTableRowSettings;

@override
TimelineModel getModel;

Person() {
dataTableInit();
timelineInit();
}
void dataTableInit() {
dataTableRowSettings = DataTableRow();
dataTableRowSettings.addSet(
DataTableColumn(
key: 'avatar',
value: avatar,
title: 'Avatar',
type: DataTableColumnType.img,
),
);

dataTableRowSettings.addSet(
DataTableColumn(
key: 'name',
value: name,
title: 'Name',
type: DataTableColumnType.text,
primaryDisplayValue: true,
),
);

dataTableRowSettings.addSet(DataTableColumn(key: 'age', value: age, title: 'Age', type: DataTableColumnType.text));
dataTableRowSettings
.addSet(DataTableColumn(key: 'phone', value: phone, title: 'Phone', type: DataTableColumnType.text));
dataTableRowSettings
.addSet(DataTableColumn(key: 'birthday', value: birthday, title: 'Birthday', type: DataTableColumnType.date));

dataTableRowSettings
.addSet(DataTableColumn(key: 'enable', value: enable, title: 'Enable', type: DataTableColumnType.boolLabel));
dataTableRowSettings.addSet(DataTableColumn(
key: 'description', value: description, title: 'Description', limit: 20, type: DataTableColumnType.text));
}

void timelineInit() {
getModel = TimelineModel();
Expand All @@ -30,8 +64,7 @@ class Person implements IDataTableRender, ISimpleSelectRender, TimelineRender {
}

String get birthdayAsString {
var dt =
birthday != null ? birthday.toIso8601String().substring(0, 10) : '';
var dt = birthday != null ? birthday.toIso8601String().substring(0, 10) : '';
return dt;
}

Expand All @@ -46,28 +79,19 @@ class Person implements IDataTableRender, ISimpleSelectRender, TimelineRender {
Person.fromJson(Map<String, dynamic> json) {
try {
id = Helper.isNotNullOrEmptyAndContain(json, 'id') ? json['id'] : -1;
name =
Helper.isNotNullOrEmptyAndContain(json, 'name') ? json['name'] : '';
name = Helper.isNotNullOrEmptyAndContain(json, 'name') ? json['name'] : '';
age = Helper.isNotNullOrEmptyAndContain(json, 'age') ? json['age'] : -1;
phone =
Helper.isNotNullOrEmptyAndContain(json, 'phone') ? json['phone'] : '';
birthdayAsString = Helper.isNotNullOrEmptyAndContain(json, 'birthday')
? json['birthday']
: null;
avatar = Helper.isNotNullOrEmptyAndContain(json, 'avatar')
? json['avatar']
: '';
enable = Helper.isNotNullOrEmptyAndContain(json, 'enable')
? json['enable']
: null;
description = Helper.isNotNullOrEmptyAndContain(json, 'description')
? json['description']
: '';

timelineInit();
phone = Helper.isNotNullOrEmptyAndContain(json, 'phone') ? json['phone'] : '';
birthdayAsString = Helper.isNotNullOrEmptyAndContain(json, 'birthday') ? json['birthday'] : null;
avatar = Helper.isNotNullOrEmptyAndContain(json, 'avatar') ? json['avatar'] : '';
enable = Helper.isNotNullOrEmptyAndContain(json, 'enable') ? json['enable'] : null;
description = Helper.isNotNullOrEmptyAndContain(json, 'description') ? json['description'] : '';
} catch (e) {
print('Person.fromJson: ${e}');
}

dataTableInit();
timelineInit();
}

Map<String, dynamic> toJson() {
Expand All @@ -85,44 +109,7 @@ class Person implements IDataTableRender, ISimpleSelectRender, TimelineRender {

@override
DataTableRow getRowDefinition() {
var settings = DataTableRow();
settings.addSet(DataTableColumn(
key: 'avatar',
value: avatar,
title: 'Avatar',
type: DataTableColumnType.img));
settings.addSet(DataTableColumn(
key: 'name',
value: name,
title: 'Name',
type: DataTableColumnType.text,
primaryDisplayValue: true));
settings.addSet(DataTableColumn(
key: 'age', value: age, title: 'Age', type: DataTableColumnType.text));
settings.addSet(DataTableColumn(
key: 'phone',
value: phone,
title: 'Phone',
type: DataTableColumnType.text));
settings.addSet(DataTableColumn(
key: 'birthday',
value: birthday,
title: 'Birthday',
type: DataTableColumnType.date));

settings.addSet(DataTableColumn(
key: 'enable',
value: enable,
title: 'Enable',
type: DataTableColumnType.boolLabel));
settings.addSet(DataTableColumn(
key: 'description',
value: description,
title: 'Description',
limit: 100,
type: DataTableColumnType.text));

return settings;
return dataTableRowSettings;
}

@override
Expand Down
59 changes: 52 additions & 7 deletions example/web/exemple_data.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "Thiago",
"name": "Thiago 1",
"age": 30,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
Expand All @@ -9,7 +9,7 @@
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Isaque",
"name": "Isaque 2",
"age": 33,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
Expand All @@ -18,7 +18,7 @@
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Leonardo",
"name": "Leonardo 3",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
Expand All @@ -27,7 +27,7 @@
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Neto",
"name": "Neto 4",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
Expand All @@ -36,7 +36,7 @@
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Cintia",
"name": "Cintia 5",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
Expand All @@ -45,7 +45,7 @@
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Marcos",
"name": "Marcos 6",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
Expand All @@ -54,7 +54,52 @@
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Carlos",
"name": "Carlos 7",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
"avatar": "https://img2.gratispng.com/20180626/fhs/kisspng-avatar-user-computer-icons-software-developer-5b327cc98b5780.5684824215300354015708.jpg",
"enable": true,
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Carlos 8",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
"avatar": "https://img2.gratispng.com/20180626/fhs/kisspng-avatar-user-computer-icons-software-developer-5b327cc98b5780.5684824215300354015708.jpg",
"enable": true,
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Carlos 9",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
"avatar": "https://img2.gratispng.com/20180626/fhs/kisspng-avatar-user-computer-icons-software-developer-5b327cc98b5780.5684824215300354015708.jpg",
"enable": true,
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Carlos 10",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
"avatar": "https://img2.gratispng.com/20180626/fhs/kisspng-avatar-user-computer-icons-software-developer-5b327cc98b5780.5684824215300354015708.jpg",
"enable": true,
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Carlos 11",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
"avatar": "https://img2.gratispng.com/20180626/fhs/kisspng-avatar-user-computer-icons-software-developer-5b327cc98b5780.5684824215300354015708.jpg",
"enable": true,
"description": "É um fato conhecido de todos que um leitor se distrairá com o conteúdo de texto legível de uma página quando estiver examinando sua diagramação."
},
{
"name": "Carlos 12",
"age": 37,
"phone": "+55 22 99778-8963",
"birthday": "1975-12-25",
Expand Down
Loading

0 comments on commit a6930a8

Please sign in to comment.