Add field published_on and title to Issue
/refs #16 Add field published_on and title to Issue and display both fields.
This commit is contained in:
@@ -237,6 +237,8 @@ class Issue(Base, BaseMixin):
|
||||
self.last_modified_date = import_data['last_modified_date']
|
||||
self.version = import_data['version']
|
||||
self.issue_number = import_data['issue_number']
|
||||
self.title = import_data['title']
|
||||
self.published_on = import_data['published_on']
|
||||
self.in_stock = import_data['in_stock']
|
||||
self.is_read = import_data['is_read']
|
||||
self.comic_id = import_data['comic_id']
|
||||
@@ -244,17 +246,20 @@ class Issue(Base, BaseMixin):
|
||||
self.story_arc_id = import_data['story_arc_id']
|
||||
|
||||
def export_dict(self) -> Dict[AnyStr, Any]:
|
||||
item: Dict[AnyStr, Any] = {}
|
||||
item['id'] = self.id
|
||||
item['created_date'] = str(self.created_date)
|
||||
item['last_modified_date'] = str(self.last_modified_date)
|
||||
item['version'] = self.version
|
||||
item['issue_number'] = self.issue_number
|
||||
item['in_stock'] = self.in_stock
|
||||
item['is_read'] = self.is_read
|
||||
item['comic_id'] = self.comic_id
|
||||
item['volume_id'] = self.volume_id
|
||||
item['story_arc_id'] = self.story_arc_id
|
||||
item: Dict[AnyStr, Any] = {
|
||||
'id': self.id,
|
||||
'created_date': str(self.created_date),
|
||||
'last_modified_date': str(self.last_modified_date),
|
||||
'version': self.version,
|
||||
'issue_number': self.issue_number,
|
||||
'title': self.title,
|
||||
'published_on': str(self.published_on),
|
||||
'in_stock': self.in_stock,
|
||||
'is_read': self.is_read,
|
||||
'comic_id': self.comic_id,
|
||||
'volume_id': self.volume_id,
|
||||
'story_arc_id': self.story_arc_id
|
||||
}
|
||||
return item
|
||||
|
||||
|
||||
@@ -295,13 +300,14 @@ class Artist(Base, BaseMixin):
|
||||
self.weblink = import_data['weblink']
|
||||
|
||||
def export_dict(self) -> Dict[AnyStr, Any]:
|
||||
item: Dict[AnyStr, Any] = {}
|
||||
item['id'] = self.id
|
||||
item['created_date'] = str(self.created_date)
|
||||
item['last_modified_date'] = str(self.last_modified_date)
|
||||
item['version'] = self.version
|
||||
item['name'] = self.name
|
||||
item['weblink'] = self.weblink
|
||||
item: Dict[AnyStr, Any] = {
|
||||
'id': self.id,
|
||||
'created_date': str(self.created_date),
|
||||
'last_modified_date': str(self.last_modified_date),
|
||||
'version': self.version,
|
||||
'name': self.name,
|
||||
'weblink': self.weblink
|
||||
}
|
||||
return item
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.thpeetz.kontor.comics.views;
|
||||
|
||||
import java.time.*;
|
||||
import java.time.format.*;
|
||||
import java.util.List;
|
||||
|
||||
import com.vaadin.flow.component.ComponentEvent;
|
||||
@@ -9,6 +11,7 @@ import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.button.ButtonVariant;
|
||||
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.datepicker.*;
|
||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
||||
import com.vaadin.flow.component.grid.*;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
@@ -43,6 +46,23 @@ public class IssueForm extends FormLayout {
|
||||
|
||||
public IssueForm(List<Comic> comics, List<Volume> volumes) {
|
||||
addClassName("issue-form");
|
||||
binder.forField(publishedOn).withConverter(new Converter<String, YearMonth>() {
|
||||
@Override
|
||||
public Result<YearMonth> convertToModel(String value, ValueContext context) {
|
||||
try {
|
||||
YearMonth result = YearMonth.parse(value);
|
||||
return Result.ok(result);
|
||||
} catch (DateTimeParseException e) {
|
||||
return Result.error("invalid year-month format");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToPresentation(YearMonth value, ValueContext context) {
|
||||
if (value == null) return "";
|
||||
return value.format(DateTimeFormatter.ofPattern("yyyy-MM"));
|
||||
}
|
||||
}).bind(Issue::getPublishedOn, Issue::setPublishedOn);
|
||||
binder.bindInstanceFields(this);
|
||||
|
||||
comic.setItems(comics);
|
||||
|
||||
Reference in New Issue
Block a user