-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Esteban/feature/editable configs #111
Conversation
first() | ||
); | ||
} | ||
|
||
update(config: Config): Observable<Config> { | ||
if (MS_NON_EDITABLE_CONFIGS_LOWER_CASE.includes(config.key.toLowerCase())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the backend make this same check ? You have to assume the UI is untrustworthy and check on the server-side too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a PR on the back end to validate
/** | ||
* Model for Machete Setting Terms | ||
*/ | ||
export class Term { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using Term here and Confirm in the backend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I have updated it to be OnlineOrderTerm
1c0627e
to
63d9fa6
Compare
beforeEach(() => { | ||
cy.apiLogin(MACHETE_ADMIN.user, MACHETE_ADMIN.password); | ||
|
||
// Stubbing the response from server here | ||
cy.fixture("settings/settings.json"); | ||
cy.intercept( | ||
{ | ||
method: "GET", | ||
url: "/api/configs", | ||
}, | ||
{ fixture: "settings/settings" } | ||
).as("configs"); | ||
cy.visit(macheteSettingsRoutes.list); | ||
|
||
cy.wait("@configs").then((i) => { | ||
Cypress.env(STUBBED_CONFGIS_KEY, i.response.body.data); | ||
const configs = Cypress.env(STUBBED_CONFGIS_KEY) as Config[]; | ||
|
||
userEditableConfigs = configs.filter( | ||
(c: Config) => | ||
c.publicConfig && | ||
!MS_NON_EDITABLE_CONFIGS_LOWER_CASE.includes(c.key.toLowerCase()) | ||
); | ||
|
||
privateConfigs = configs.filter( | ||
(c: Config) => | ||
!c.publicConfig && | ||
MS_NON_EDITABLE_CONFIGS_LOWER_CASE.includes(c.key.toLowerCase()) | ||
); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is injecting test config data from fixtures/settings
into the http response
cy.wait("@configs").then(() => { | ||
configs = Cypress.env(ENV_KEY_MACHETE_CONFIGS) as Config[]; | ||
userEditableConfigs = configs.filter( | ||
(c: Config) => | ||
c.publicConfig && | ||
!MS_NON_EDITABLE_CONFIGS_LOWER_CASE.includes(c.key.toLowerCase()) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also injecting test data in the http response
path: "settings", | ||
loadChildren: () => | ||
import("./machete-settings/machete-settings.module").then( | ||
(m) => m.MacheteSettingsModule | ||
), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this lazy-loads the module
return this.http | ||
.put(`${this.uriBase}/${config.id}`, config, { withCredentials: true }) | ||
.pipe( | ||
catchError((error) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
const errorAsText: string = error["statusText"] as string; | ||
this.appMessages.showErrors({ | ||
Error: `${errorAsText}: Contact Machete support.`, | ||
}); | ||
console.log(error); | ||
return throwError(error); | ||
}), | ||
pluck("data"), | ||
map((data) => data as Config), | ||
tap(() => { | ||
this.appMessages.showSuccess({ | ||
label: "Success", | ||
message: "Record Saved", | ||
}); | ||
}) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catchError
will break the stream and user will receive the feedback
remove unused bootstrap routing for edit component bootstrap edit component handle confirm save and cancel implement edit configs service Handle SAVE errors and return new reference on `getOne` Include description in template Exclude rows not editable by users user-defined settings - exclude from list - validate against edits Better titles define user-defined settings implement terms editor e2e testing stub settings reponses edit component unit tests fix confitional render better type names better file name better online order term naming
63d9fa6
to
2e41751
Compare
<div class="p-field p-col-12 p-input-filled" [hidden]="r.key === TERMS_KEY"> | ||
<span class="p-float-label"> | ||
<input | ||
pInputText | ||
[(ngModel)]="r.value" | ||
id="value" | ||
name="value" | ||
required | ||
ngModel | ||
#value="ngModel" | ||
/> | ||
<label for="value">Value</label> | ||
</span> | ||
<small class="p-error" *ngIf="!r.value" | ||
>Value is required</small | ||
> | ||
</div> | ||
<div class="p-field p-col-12" *ngIf="r.key === TERMS_KEY"> | ||
<app-machete-settings-term-form [termsAsString]="r.value" (termChange)="onChildTermChange($event, r)"></app-machete-settings-term-form> | ||
</div> | ||
</div> | ||
</form> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic to determine if form will display an input field or the onlineTerms
form. The terms form is in a child component: app-machete-settings-term-form
@@ -0,0 +1,119 @@ | |||
<ng-container *ngIf="record$ | async as r"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foo$ | async as bar
aka async pipe is a new ng feature that handles the subscribe/unsubscribe logic automatically
Changes:
Module for machete configs (called machete settings in ui) within the Configs module