Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test app
Browse files Browse the repository at this point in the history
zinyando committed Nov 16, 2023
1 parent 1c736b8 commit c1373bd
Showing 6 changed files with 41 additions and 18 deletions.
6 changes: 3 additions & 3 deletions packages/surrealdb/tests/dummy/app/components/sign-in-form.js
Original file line number Diff line number Diff line change
@@ -13,9 +13,9 @@ export default class SignInForm extends Component {
@action async signin() {
try {
await this.surreal.signin({
NS: config.surreal.NS,
DB: config.surreal.DB,
SC: 'account',
namespace: config.surreal.namespace,
database: config.surreal.database,
scope: 'account',
email: this.email,
pass: this.pass,
});
6 changes: 3 additions & 3 deletions packages/surrealdb/tests/dummy/app/components/sign-up-form.js
Original file line number Diff line number Diff line change
@@ -13,9 +13,9 @@ export default class SignUpForm extends Component {
@action async signup() {
try {
await this.surreal.signup({
NS: config.surreal.NS,
DB: config.surreal.DB,
SC: 'account',
namespace: config.surreal.namespace,
database: config.surreal.database,
scope: 'account',
email: this.email,
pass: this.pass,
});
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ export default class SurrealIndexController extends Controller {

@tracked data;
@tracked name = '';
@tracked searchName = '';

@action
async loadData(model) {
@@ -42,6 +43,13 @@ export default class SurrealIndexController extends Controller {
await person.delete();
}

@action
async searchPerson() {
await this.store.search('person', {
where: [`name = "${this.searchName}"`],
});
}

@action
async closeConnection() {
await this.surreal.close();
24 changes: 15 additions & 9 deletions packages/surrealdb/tests/dummy/app/surreal/index/template.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{{#unless this.surreal.authenticated}}
<button type='button' {{on 'click' this.signin}}>Sign in</button>
<button type="button" {{on "click" this.signin}}>Sign in</button>
{{/unless}}
<button type='button' {{on 'click' (fn this.loadData 'person')}}>Load Data</button>
<button type='button' {{on 'click' this.closeConnection}}>Close Connection</button>
<button type="button" {{on "click" (fn this.loadData "person")}}>Load Data</button>
<button type="button" {{on "click" this.closeConnection}}>Close Connection</button>

<div>
<label for='user-question'>Enter a name:</label>
<Input id='add-person' @type='text' @value={{this.name}} />
<button type='button' {{on 'click' this.addPerson}}>Add Person</button>
<label for="user-question">Enter a name:</label>
<Input id="add-person" @type="text" @value={{this.name}} />
<button type="button" {{on "click" this.addPerson}}>Add Person</button>
</div>

<div>
<label for="user-question">Search:</label>
<Input id="search-person" @type="search" @value={{this.searchName}} />
<button type="button" {{on "click" this.searchPerson}}>Search Person</button>
</div>

<div>
@@ -23,10 +29,10 @@
<tr>
<td>{{item.name}}</td>
<td><button
type='button'
{{on 'click' (fn this.deletePerson item)}}
type="button"
{{on "click" (fn this.deletePerson item)}}
>Delete Person</button></td>
<td><LinkTo @route='surreal.person' @model={{item}}>View Person</LinkTo></td>
<td><LinkTo @route="surreal.person" @model={{item}}>View Person</LinkTo></td>
</tr>
{{else}}
Click load data button to display something here!!
Original file line number Diff line number Diff line change
@@ -9,4 +9,11 @@ export default class SurrealPersonController extends Controller {
async updatePerson(item) {
await this.store.update(item.id, item);
}

@action
async modifyPerson(item) {
await this.store.modify(item, [
{ op: 'replace', path: '/name', value: item.name },
]);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<div>
<label for='user-question'>Person name:</label>
<Input id='add-person' @type='text' @value={{this.model.name}} />
<button type='button' {{on 'click' (fn this.updatePerson this.model)}}>Update
<label for="user-question">Person name:</label>
<Input id="add-person" @type="text" @value={{this.model.name}} />
<button type="button" {{on "click" (fn this.updatePerson this.model)}}>Update
Person</button>
<button type="button" {{on "click" (fn this.modifyPerson this.model)}}>Modify
Person</button>
</div>

0 comments on commit c1373bd

Please sign in to comment.