// Goal of this file is to re-create a TODO app from http://todomvc.com // This file has "advanced" features in the sense that they might not yet be implemented by Wasp: this is just a proposal. app todoMVC { title: "ToDo MVC" } entity Task { description :: string, isDone :: boolean } // IDEA: `@connect Task as taskList` -> this would make it more obvious what is available, also we don't need to automatically try to guess what to import. page Main { route: "/", content: {=jsx

todos

{/* Toggle all */}
{ /* Filter here -> that is not supported by TaskList yet. */ }
{ /* TODO: This is maybe not very nice, inlined like this. Also, we directly address taskList here, while in TaskList and in CreateTaskForm we address it implicitly. */ } { this.props.taskList.filter(task => !task.isDone).length } items left { /* TODO: Can we also make this nicer? */ } {/* Clear completed */} { this.props.taskList.some(t => t.isDone) && }
jsx=}, style: {=css div { color: green; } .mainContainer { display: flex; flex-direction: column; align-items: center; } .taskListContainer { width: 60%; } css=} } // TODO: This part is not currently supported at all. entity-form CreateTaskForm { fields: { description: { placeholder: "What do you want to do?" }, isDone: { show: false, defaultValue: false // Although not shown, this field will be set to "false". } }, submit: { button: { show: false }, onEnter: true, // Resets fields to their initial values after the submission. resetAllFields: true } } // TODO: This part is not currently supported at all. entity-list TaskList { allowItemEditing: true, allowItemDeletion: true, // Items can be deleted, and this also deletes them for real. fields: { description: { // The contract for render is: user can provide a function that: // - receives a task as an input // - returns a React Node or something that can be rendered by JSX // - does not depend on any outer context render: {=js (task) => { if (task.isDone) return ({task.description}) return task.description } js=} } } } // TODO: This part is not currently supported at all. // Idea would be to generate a script (bash) that does deployment and would be called // with `npm deploy`, from generated frontend. // NOTE: For now we don't care about environments (staging) yet, there is just one environment to deploy to (production). deployment { frontend: { // TODO: In case of github, this would go into CNAME file. // NOTE: optional. customDomain: 'todo-app.examples.wasp-lang.dev', github: { // NOTE: For now we allow only one deployment method (in this case "github") at once. branch: 'gh-pages' // NOTE: optional. } } }