Open HannesRammer opened 8 years ago
Hello I cant seem to find a way to remove a nested element using polymer 1.0
I have a list of tables with each with a list of columns.
when I click on removing on column 2 of table 2 I only get the column objects inside model.item
I also get the index of the column, but I cant find a way to determine the correct table.
is this maybe a bug??
stackoverflow
createMigrationTable.html
`
` createMigrationTable.dart ` @HtmlImport("createMigrationTable.html") library dartabase.poly.createMigrationTable;
import "package:polymer_elements/iron_pages.dart"; import "package:polymer_elements/paper_material.dart"; import "package:polymer_elements/paper_button.dart"; import "package:polymer_elements/paper_input.dart"; import "../poly/table.dart"; import "package:polymer/polymer.dart"; import "package:web_components/web_components.dart";
@PolymerRegister("custom-create-migration-table") class CreateMigrationTable extends PolymerElement { @property List
CreateMigrationTable.created() : super.created();
@reflectable addTable(event, [_]) { Table table = new Table(name:"defaultName",columns: [{ "name":"defaultName", "type":["BINT", "BINT UNSIGNED", "VARBINARY", "VARCHAR" ], "def":"", "nil":true }]); /Map table = { "tableName":"defaultTableName", "columns":[{ "name":"defaultName", "type":"defaultType", "default":"", "notNull":true }] };/ //createTables.add(table); add("createTables", table); }
@reflectable transition(event, [_]) { IronPages ip = Polymer.dom(this.root).querySelector("iron-pages"); ip.selectNext(); }
@reflectable void addColumn(event, [_]) { var model = new DomRepeatModel.fromEvent(event); model.add("item.columns", { "name":"defaultName", "type":"", "def":"", "nil":true }); }
@reflectable void removeColumn(event, [_]) { var model = new DomRepeatModel.fromEvent(event); print(convertToDart(model.item)); model.removeItem("item", model.item); model.removeItem("item", convertToDart(model.item)); } void ready() { print("$runtimeType::ready()"); }
}
` tabel.dart ` import "package:polymer/polymer.dart"; import "package:web_components/web_components.dart";
class Table extends JsProxy { @reflectable final String name; @reflectable List columns;
Table({this.name, this.columns});
The problem seems to be that var model = new DomRepeatModel.fromEvent(event); just returns a map, not the Test instance from the collection dom-repeat iterates over. I don't know if this is as designed or a bug.
var model = new DomRepeatModel.fromEvent(event);
Test
dom-repeat
Hello I cant seem to find a way to remove a nested element using polymer 1.0
I have a list of tables with each with a list of columns.
when I click on removing on column 2 of table 2 I only get the column objects inside model.item
I also get the index of the column, but I cant find a way to determine the correct table.
is this maybe a bug??
stackoverflow
createMigrationTable.html
`
import "package:polymer_elements/iron_pages.dart"; import "package:polymer_elements/paper_material.dart"; import "package:polymer_elements/paper_button.dart"; import "package:polymer_elements/paper_input.dart"; import "../poly/table.dart"; import "package:polymer/polymer.dart"; import "package:web_components/web_components.dart";
@PolymerRegister("custom-create-migration-table") class CreateMigrationTable extends PolymerElement { @property List
CreateMigrationTable.created() : super.created();
@reflectable addTable(event, [_]) { Table table = new Table(name:"defaultName",columns: [{ "name":"defaultName", "type":["BINT", "BINT UNSIGNED", "VARBINARY", "VARCHAR" ], "def":"", "nil":true }]); /Map table = { "tableName":"defaultTableName", "columns":[{ "name":"defaultName", "type":"defaultType", "default":"", "notNull":true }] };/ //createTables.add(table); add("createTables", table); }
@reflectable transition(event, [_]) { IronPages ip = Polymer.dom(this.root).querySelector("iron-pages"); ip.selectNext(); }
@reflectable void addColumn(event, [_]) { var model = new DomRepeatModel.fromEvent(event); model.add("item.columns", { "name":"defaultName", "type":"", "def":"", "nil":true }); }
@reflectable void removeColumn(event, [_]) { var model = new DomRepeatModel.fromEvent(event); print(convertToDart(model.item)); model.removeItem("item", model.item); model.removeItem("item", convertToDart(model.item)); } void ready() { print("$runtimeType::ready()"); }
}
class Table extends JsProxy { @reflectable final String name; @reflectable List columns;
Table({this.name, this.columns});
}
The problem seems to be that
var model = new DomRepeatModel.fromEvent(event);
just returns a map, not theTest
instance from the collectiondom-repeat
iterates over. I don't know if this is as designed or a bug.