Skip to content

Commit

Permalink
Getting started kind of complete
Browse files Browse the repository at this point in the history
  • Loading branch information
lolgzs committed Apr 11, 2018
1 parent 480d68b commit e7fb00f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions Chapters/GettingStarted.pillar
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ as shown in screenshot *@ToDoApplication*.



!!! Models definition
!!! Model definition

QCMagritte applications are model driven. That means we will put some effort in
describing models handled by the application. Then we expect QCMagritte to
Expand All @@ -91,6 +91,9 @@ ToDoApplication>>model
^TodoListModel default
]]]


!!!! ToDo items

For ToDoApplication, we need some ==ToDo items== that have a ==title==, a ==description==
and a ==completion== status. Let's declare this class as a subclass of ==QCObject==:

Expand Down Expand Up @@ -157,4 +160,45 @@ TodoItem>>descriptionCompleted
label: 'Completed';
priority: 300;
yourself
]]]
]]]


!!!! Putting all together

Finally, we need a way to store created Todo items. We will talk about Glorp
persistence in the next chapter. For now, let's use an
==OrderedCollection==. Add instance variable ==todoItems== in ==TodoListModel==
as follow:

[[[
QCBootstrapApplicationModel subclass: #TodoListModel
instanceVariableNames: 'todoItems'
classVariableNames: ''
category: 'Tutorial-Model'


TodoListModel>>todoItems
^todoItems ifNil: [ todoItems := OrderedCollection new ]

TodoListModel>>todoItems: aCollection
todoItems := aCollection
]]]

Then describe this variable using Magritte description
==MAToMaManyRelationDescription==:

[[[
TodoListModel>>descriptionTodoItems
<magritteDescription>
^MAToManyRelationDescription new
label: 'Todo';
accessor: #todoItems;
priority: 200;
classes: { TodoItem };
yourself
]]]

Go back to your web browser, you should be able to create / update / delete some
items (see *@ToDoWithModel*)

+ToDo application front page>file://figures/qcmagritte_todo_with_model.png|width=70|label=ToDoWithModel+
Binary file added Chapters/figures/qcmagritte_todo_with_model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e7fb00f

Please sign in to comment.