-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use ember-resources for ember-caluma fetching
- Loading branch information
Showing
40 changed files
with
616 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,6 @@ | |
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try | ||
|
||
# mirage | ||
/mirage/mirage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import CaseModel from "@projectcaluma/ember-core/caluma-query/models/work-item"; | ||
|
||
export default class CustomCaseModel extends CaseModel { | ||
static fragment = `{ | ||
createdAt | ||
modifiedAt | ||
createdByUser | ||
createdByGroup | ||
closedAt | ||
closedByUser | ||
closedByGroup | ||
status | ||
meta | ||
document { | ||
id | ||
form { | ||
name | ||
} | ||
} | ||
}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,7 @@ | ||
import Controller from "@ember/controller"; | ||
import getCaseQuery from "caluma-portal-demo/gql/queries/get-case"; | ||
import { queryManager } from "ember-apollo-client"; | ||
import { task, lastValue } from "ember-concurrency"; | ||
import QueryParams from "ember-parachute"; | ||
|
||
export default class CasesDetailController extends Controller.extend( | ||
new QueryParams().Mixin | ||
) { | ||
@queryManager apollo; | ||
|
||
setup() { | ||
this.fetchCase.perform(); | ||
} | ||
reset() { | ||
this.fetchCase.cancelAll(); | ||
} | ||
|
||
@lastValue("fetchCase") case; | ||
@task | ||
*fetchCase() { | ||
if (typeof this.model === "object" && this.model) { | ||
return this.model; | ||
} | ||
|
||
const caseNode = yield this.apollo.query( | ||
{ | ||
query: getCaseQuery, | ||
variables: { caseId: this.model }, | ||
}, | ||
"allCases.edges" | ||
); | ||
return caseNode.map(({ node }) => node)[0]; | ||
export default class CasesDetailController extends Controller { | ||
get case() { | ||
return this.model.value[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Controller from "@ember/controller"; | ||
|
||
export default class CasesDetailEditController extends Controller { | ||
get case() { | ||
return this.model.value[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import CasesDetailRoute from "caluma-portal-demo/cases/detail/index/route"; | ||
|
||
export default class CasesDetailEditRoute extends CasesDetailRoute {} | ||
export default class CasesDetailEditRoute extends CasesDetailRoute { | ||
model() { | ||
return this.modelFor("cases.detail"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{{#if @model}} | ||
<CfContent @documentId={{@model.document.id}} /> | ||
<CfContent @documentId={{this.case.document.id}} /> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,7 @@ | ||
import Route from "@ember/routing/route"; | ||
import getCaseQuery from "caluma-portal-demo/gql/queries/get-case"; | ||
import { queryManager } from "ember-apollo-client"; | ||
|
||
export default class CasesDetailRoute extends Route { | ||
@queryManager apollo; | ||
async model() { | ||
const model = this.modelFor("cases.detail"); | ||
if (typeof model === "object" && model) { | ||
return model; | ||
} | ||
|
||
const caseRecord = await this.apollo.query( | ||
{ | ||
query: getCaseQuery, | ||
variables: { caseId: model }, | ||
}, | ||
"allCases.edges" | ||
); | ||
return caseRecord.map(({ node }) => node)[0]; | ||
model() { | ||
return this.modelFor("cases.detail"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import Route from "@ember/routing/route"; | ||
|
||
import { useCalumaQuery } from "@projectcaluma/ember-core/caluma-query"; | ||
import { allCases } from "@projectcaluma/ember-core/caluma-query/queries"; | ||
export default class CasesDetailRoute extends Route { | ||
model(params) { | ||
return params.id; | ||
model({ case_id }) { | ||
const caseQuery = useCalumaQuery(this, allCases, () => ({ | ||
options: { pageSize: 1 }, | ||
filter: [{ id: case_id }], | ||
})); | ||
|
||
return caseQuery; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.