Skip to content

Commit

Permalink
useTemplate now has optional templatedata
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaden505 committed Dec 11, 2024
1 parent 64a44c7 commit eb5a068
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/public/views/Logs/Create/TemplatedLogCreationModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,26 @@ export class TemplatedLogCreationModel extends LogCreationModel {
constructor(onCreation, relations, templateKey, templateData) {

Check warning on line 56 in lib/public/views/Logs/Create/TemplatedLogCreationModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Logs/Create/TemplatedLogCreationModel.js#L56

Added line #L56 was not covered by tests
super(onCreation, relations);

this._templateData = templateData;

/**
* @type {logTemplateKey|null}
* @private
*/
this._templateKey = null;

if (templateKey) {
this.useTemplate(templateKey);
this.useTemplate(templateKey, templateData);

Check warning on line 66 in lib/public/views/Logs/Create/TemplatedLogCreationModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Logs/Create/TemplatedLogCreationModel.js#L65-L66

Added lines #L65 - L66 were not covered by tests
}
}

/**
* Defines the template to use, defined by its key
*
* @param {logTemplateKey|null} key the key of the template to use (there may be no model for the given key)
* @param {object} templateData the template data of the log
* @param {object} [templateData={}] the optional template data
* @return {void}
*/
useTemplate(key) {
const templateModel = logTemplatesFactory(key, this._templateData);
useTemplate(key, templateData={}) {

Check failure on line 77 in lib/public/views/Logs/Create/TemplatedLogCreationModel.js

View workflow job for this annotation

GitHub Actions / linter

Operator '=' must be spaced
const templateModel = logTemplatesFactory(key, templateData);

Check warning on line 78 in lib/public/views/Logs/Create/TemplatedLogCreationModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Logs/Create/TemplatedLogCreationModel.js#L77-L78

Added lines #L77 - L78 were not covered by tests
if (templateModel) {
templateModel.bubbleTo(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class OnCallLogTemplate extends Observable {
* @return {boolean} true if the form is valid
*/
get isValid() {
console.log(this.formData)

Check failure on line 131 in lib/public/views/Logs/Create/templates/OnCallLogTemplate.js

View workflow job for this annotation

GitHub Actions / linter

Unexpected console statement

Check failure on line 131 in lib/public/views/Logs/Create/templates/OnCallLogTemplate.js

View workflow job for this annotation

GitHub Actions / linter

Missing semicolon

Check warning on line 131 in lib/public/views/Logs/Create/templates/OnCallLogTemplate.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Logs/Create/templates/OnCallLogTemplate.js#L131

Added line #L131 was not covered by tests
return Boolean(this.formData.shortDescription.length >= 4 && this.formData.shortDescription.length <= 100
&& this.formData.detectorOrSubsystem
&& this.formData.severity
Expand Down

0 comments on commit eb5a068

Please sign in to comment.