-
Notifications
You must be signed in to change notification settings - Fork 12
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
editor: fix issues #338
editor: fix issues #338
Conversation
a2e12a6
to
1a803ec
Compare
1a803ec
to
7bed2d2
Compare
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.
There's a typo in commit message: routing
instead of rooting
.
And you can reference the solved issues to close them automatically.
@each $breakpoint in map-keys($grid-breakpoints) { | ||
@include media-breakpoint-up($breakpoint) { | ||
$infix: breakpoint-infix($breakpoint, $grid-breakpoints); | ||
@each $prop, $abbrev in (width: w, height: h) { | ||
@each $size, $length in $sizes { | ||
.#{$abbrev}#{$infix}-#{$size} { #{$prop}: $length !important; } | ||
} | ||
} | ||
} | ||
} |
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.
Be careful, I think it can create a black hole 🤣
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.
an after that, @jma tells me that he isn't a CSS king .... What's the truth ?
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.
It is just a copy/paste from the web.
// }, | ||
// (error) => { | ||
// this.error = error; | ||
// this._spinner.hide(); | ||
// } |
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.
Better to remove instead of commenting, Git have the history!
@@ -30,6 +30,7 @@ | |||
</li> | |||
</ul> | |||
<div class="main-content"> | |||
{{types}} |
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.
Must be removed
// /** | ||
// * Hide the array and remove all the elements | ||
// */ | ||
// hide() { | ||
// this.field.hide = true; | ||
// } |
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.
Better to remove instead of commenting
<div> | ||
<legend *ngIf="to.label" [tooltip]="to.description">{{ to.label }} </legend> | ||
<div class="{{field.parent.templateOptions.cssClass}}"> | ||
<legend *ngIf="to.label" [tooltip]="to.description">label {{ to.label }}</legend> |
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.
label
should be removed.
class="dropdown-menu" | ||
role="menu" | ||
aria-labelledby="button-basic"> | ||
<div id="dropdown-basic" *dropdownMenu class="dropdown-menu" role="menu" aria-labelledby="button-basic"> |
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.
aria-labelledby
should be removed as it refer to a non-existing ID.
constructor(private _editorService: EditorService) { | ||
super(); | ||
} | ||
|
||
getIndex() { |
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.
Doc block is missing for constructor and getIndex
getIndex() { | ||
if (this.field.parent.type === 'array') { | ||
return Number(this.field.key); | ||
} | ||
return null; | ||
} | ||
|
||
getFieldGroup(field: FormlyFieldConfig) { |
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.
doc blocks are missing for getIndex
and getFieldGroup
add() { | ||
if (this.field.parent.type === 'array') { | ||
const i = this.getIndex() + 1; | ||
console.log('i:', i); |
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.
Remove console log
I tested the issues and some of them seem not to be corrected:
|
2601da7
to
e411862
Compare
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.
Most of comments are cosmetics ;-) you can skip them
if (!field.templateOptions.longMode) { | ||
return false; | ||
} | ||
return ( | ||
!field.templateOptions.required && | ||
!field.hide && | ||
field.hideExpression == null | ||
); |
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 like (me and myself) ternary instruction. In this case
return (!field.templateOptions.longMode)
? false
: ( !field.templateOptions.required &&
!field.hide &&
field.hideExpression == null
);
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.
Seem to me more difficult to read. @sebastiendeleze any advises?
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.
+1 for use ternary, but only if expression is quite simple. In this case, it is difficult to read in my opinion. But I would suggest to merge statements, like this:
return (
field.templateOptions.longMode &&
!field.templateOptions.required &&
!field.hide &&
field.hideExpression == null
);
if (!field) { | ||
return false; | ||
} | ||
return field.templateOptions && field.templateOptions.isRoot && field.templateOptions.isRoot === true; |
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.
ternary is cosmetic ;-)
return (!field)
? false
: field.templateOptions && field.templateOptions.isRoot && field.templateOptions.isRoot === true;
<!-- section title --> | ||
<ng-template #title let-f="f"> | ||
<div class="header"> | ||
<label class="mb-0" *ngIf="f.templateOptions.label" [attr.for]="f.id" [tooltip]="f.templateOptions.description"> |
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.
maybe introduce the possibility to add classes on label ?
See https://github.com/rero/ng-core/pull/339/files#diff-869d70bf847d429975de17d5bba4a3b9d16c3ce727a971e147a93deaaa8d0fcdR25
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 prefer the more generic approach: https://github.com/rero/ng-core/pull/338/files#diff-869d70bf847d429975de17d5bba4a3b9d16c3ce727a971e147a93deaaa8d0fcdR24
* @param field - FormlyFieldConfig, the correspondig form field config | ||
* @returns boolean, true if the menu should be displayed | ||
*/ | ||
hasMenu(field: FormlyFieldConfig) { |
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.
ternary ?
getIndex() { | ||
if (this.field.parent.type === 'array') { | ||
return Number(this.field.key); | ||
} | ||
return null; |
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 one is the perfect one for a ternary return :
return (this.field.parent.type === 'array') ? Number(this.field.key) : null;
if (this.field.parent.type === 'array') { | ||
return this.field.parent.templateOptions.canAdd(); | ||
} | ||
return false; |
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.
ternary ?
const i = this.getIndex() + 1; | ||
return this.field.parent.templateOptions.add(this.getIndex() + 1); |
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.
Either use i
, either delete line 173
if (this.field.parent.type === 'object') { | ||
return this._editorService.canHide(this.field); | ||
} | ||
if (this.field.parent.type === 'array') { | ||
return this.field.parent.templateOptions.canRemove(); | ||
} | ||
return false; |
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.
switch ?
if (this.field.parent.type === 'array') { | ||
return this.field.parent.templateOptions.canAdd(); | ||
} | ||
return false; |
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.
ternary again ?
const i = this.getIndex() + 1; | ||
return this.field.parent.templateOptions.add(this.getIndex() + 1); |
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.
use i
or delete the line 107
3f40ac9
to
51f4a19
Compare
Based on the schema property here https://github.com/rero/sonar/blob/staging/sonar/modules/documents/jsonschemas/documents/document-v1.0.0_src.json#L313, I think the subtitles must not be present in the editor by default: I think this is related to #338 (comment) and the |
dab1625
to
75f2990
Compare
d3a0de3
to
2955b8e
Compare
ba2a45f
to
0529063
Compare
0529063
to
3c53cb3
Compare
3c53cb3
to
f289992
Compare
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.
Commit message approved.
* Fixes tester document search routing. * Removes useless log messages. * Fixes import paths. * Replaces the css classes such as `editor-title` by a `card` wrapper. * Moves some common code lines in the editor service. * Moves the field label html code into a specific component. * Adds new `containerCSSClass`, `itemCSSClass` and `cssClass` to allow field grid positions. * Renders the hide/show/clone button in the children field instead of the parent (array, object) component. * Adds external link support for remote typeahead editor component. * Closes rero#328. * Closes rero#327. * Closes rero#325. * Closes rero#248. * Closes rero#242. * Closes rero/rero-ils#1604. * Closes rero/rero-ils#1601. Co-Authored-by: Johnny Mariéthoz <[email protected]>
f289992
to
4198063
Compare
@@ -14,14 +14,14 @@ | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
import { Component } from '@angular/core'; | |||
import { Component, OnInit } from '@angular/core'; |
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.
On Init is not used.
editor-title
by acard
wrapper.containerCSSClass
,itemCSSClass
andcssClass
to allowfield grid positions.
the parent (array, object) component.
Co-Authored-by: Johnny Mariéthoz [email protected]
Why are you opening this PR?
How to test?
-Start the demo server and go to
http://localhost:4200/editor
.Code review check list