Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/app/content/html/html-editor/html-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { filter } from 'rxjs/operators';
import { HtmlParserService } from '../html-parser/html-parser.service';
import { SafePipe } from '../../safe.pipe';
import { FormsModule } from '@angular/forms';
import { NgxJoditComponent } from 'ngx-jodit';
import { JoditConfig, NgxJoditComponent } from 'ngx-jodit';
import { NgIf } from '@angular/common';

const basicButtons = [
Expand Down Expand Up @@ -116,7 +116,7 @@ export class HtmlEditorComponent implements OnInit, OnChanges {
@Input() buttonMode: HtmlButtonMode;
ButtonModeType = HtmlButtonMode;

editorConfig: object;
editorConfig: JoditConfig;

displayContent = '';

Expand Down Expand Up @@ -190,14 +190,15 @@ export class HtmlEditorComponent implements OnInit, OnChanges {
}

const focusNode = editor.selection.sel.focusNode;
const savedSelection = editor.selection.save();

component.elementSelectorSubscription = component.messageService.elementSelector.subscribe(
(element: MauroItem & Pathable) => {
if (!element) {
return;
}

this.createAndInsertLink(this, editor, focusNode, element);
this.createAndInsertLink(this, editor, focusNode, element, savedSelection);
}
);

Expand All @@ -211,7 +212,7 @@ export class HtmlEditorComponent implements OnInit, OnChanges {
if (!component.allowAutocompleteSearch) {
return;
}

const savedSelection = editor.selection.save();
const focusNode = editor.selection.sel.focusNode;

component.dialog
Expand All @@ -223,7 +224,8 @@ export class HtmlEditorComponent implements OnInit, OnChanges {
component,
editor,
focusNode,
response.selected
response.selected,
savedSelection
);
});
}
Expand All @@ -232,7 +234,8 @@ export class HtmlEditorComponent implements OnInit, OnChanges {
component: HtmlEditorComponent,
editor: any,
focusNode: any,
element: MauroItem & Pathable
element: MauroItem & Pathable,
savedSelection: any
) {
const path
= element.path ?? component.pathNames.createFromBreadcrumbs(element);
Expand All @@ -251,8 +254,9 @@ export class HtmlEditorComponent implements OnInit, OnChanges {
const html = editor.create.fromHTML(
`<a href='${pathWithoutBranch}' title='${element.label}'>${element.label}</a>`
);

editor.selection.setCursorIn(focusNode);
editor.selection.restore(savedSelection);
// editor.selection.setCursorIn(focusNode);
editor.selection.focus();
editor.selection.insertHTML(html);

return { path, element };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ describe('DefaultProfileProviderService', () => {
sections: [
{
name: 'Default',
fields
fields,
sections: []
}
]
};
Expand Down
1 change: 1 addition & 0 deletions src/app/mauro/profiles/default-profile-provider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ export class DefaultProfileProviderService implements ProfileProviderService {
sections: [
{
name: defaultProfileSectionName,
sections: [],
fields
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h4 mat-dialog-title>Add New Profile</h4>
[disabled]="!data.selectedProfile"
class="custom"
>
Save Changes
Add Profile
</button>
</div>
</div>
Expand Down
167 changes: 5 additions & 162 deletions src/app/modals/edit-profile-modal/edit-profile-modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,171 +37,14 @@ <h4 mat-dialog-title>Edit Profile - {{ data.profileName }}</h4>
finalised.
</mdm-alert>
<table
*ngIf="this.profileData"
*ngIf="this.profileData && this.profileData.sections.length > 0"
class="table table-bordered"
role="presentation"
>
<tbody *ngFor="let section of this.profileData?.sections">
<tr>
<td [attr.colspan]="2" class="detailsRowHeader">
{{ section.name }}
</td>
</tr>
<tr *ngFor="let field of section.fields">
<td class="detailsRowHeader" class="detailsRowHeader">
{{ field.fieldName }}
<span *ngIf="field.minMultiplicity > 0">*</span>
<span
*ngIf="field.description"
style="float: right"
class="fas fa-info-circle helpIcon"
[matTooltip]="field.description"
matTooltipPosition="after"
></span>
</td>
<td class="elementDetailDescription">
<mdm-content-editor
[(content)]="field.currentValue"
id="{{ field.fieldName }}"
[inEditMode]="!field.uneditable"
[rootElement]="data.catalogueItem"
*ngIf="field.dataType === 'text'"
></mdm-content-editor>

<input
type="checkbox"
style="
width: 20px;
height: 20px;
position: relative;
vertical-align: middle;
"
*ngIf="formOptionsMap[field.dataType] === 'checkbox'"
[checked]="field.currentValue === 'true'"
(change)="field.currentValue = $event.target.checked"
name="{{ field.fieldName }} + {{ section.name }}"
[required]="field.minMultiplicity > 0"
[disabled]="field.readOnly"
/>
<div
*ngIf="
field.dataType !== 'folder' &&
field.dataType !== 'model' &&
field.dataType != 'text' &&
field.dataType != 'date' &&
field.dataType != 'datetime' &&
field.dataType != 'boolean' &&
field.dataType != 'folder' &&
field.dataType != 'boolean' &&
field.dataType != 'enumeration'
"
>
<span *ngIf="field.uneditable">{{ field.currentValue }}</span>
<input
*ngIf="!field.readOnly"
matInput
type="{{ formOptionsMap[field.dataType] }}"
name="{{ field.fieldName }} + {{ section.name }}"
[(ngModel)]="field.currentValue"
value="field.currentValue"
[ngClass]="{
'outlined-input form-control':
formOptionsMap[field.dataType] != 'checkbox'
}"
[required]="field.minMultiplicity > 0"
/>
</div>
<input
*ngIf="field.dataType === 'date'"
matInput
type="date"
name="{{ field.fieldName }} + {{ section.name }}"
[(ngModel)]="field.currentValue"
value="{{ field.currentValue }}"
[ngClass]="{
'outlined-input form-control':
formOptionsMap[field.dataType] != 'checkbox'
}"
[required]="field.minMultiplicity > 0"
[disabled]="field.readOnly"
/>
<input
*ngIf="field.dataType === 'datetime'"
matInput
type="datetime-local"
name="{{ field.fieldName }} + {{ section.name }}"
[(ngModel)]="field.currentValue"
value="{{ field.currentValue }}"
[ngClass]="{
'outlined-input form-control':
formOptionsMap[field.dataType] != 'checkbox'
}"
[required]="field.minMultiplicity > 0"
[disabled]="field.readOnly"
/>
<div *ngIf="field.dataType === 'model'">
<input
type="text"
matInput
type="text"
name="{{ field.fieldName }} + {{ section.name }}"
[(ngModel)]="field.currentValue"
value="{{ field.currentValue }}"
[ngClass]="{
'outlined-input form-control':
formOptionsMap[field.dataType] != 'checkbox'
}"
[required]="field.minMultiplicity > 0"
[disabled]="field.readOnly"
/>
<button
*ngIf="!field.readOnly"
mat-stroked-button
type="button"
color="primary"
(click)="showAddElementToMarkdown(field)"
style="top: 3px; margin-left: 4px"
>
<span class="fas fa-plus"></span>
Add Data Model
</button>
</div>
<div *ngIf="field.dataType === 'enumeration'">
<mat-form-field appearance="outline">
<mat-select
[(ngModel)]="field.currentValue"
name="{{ field.fieldName }} + {{ section.name }}"
[disabled]="field.readOnly"
>
<mat-option
*ngFor="let value of sortBy(field.allowedValues)"
[value]="value"
>
{{ value }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div *ngIf="field.dataType === 'folder'">
<mdm-model-selector-tree
[treeSearchDomainType]="'Folder'"
[justShowFolders]="true"
[ngModel]="field.currentValue"
name="Folder"
(ngModelChange)="field.currentValue = $event"
[accepts]="['Folder']"
ngDefaultControl
[showValidationError]="field.minMultiplicity > 0"
[isRequired]="field.minMultiplicity > 0"
[multiple]="true"
[hideSelectedElements]="false"
>
</mdm-model-selector-tree>
</div>
<mat-error *ngIf="getValidationError(field.metadataPropertyName)">
{{ getValidationError(field.metadataPropertyName).message }}
</mat-error>
</td>
<tbody>
<tr mdm-edit-profile-section
*ngFor="let section of this.profileData?.sections"
[profileSection]="section">
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ import { MatTooltip } from '@angular/material/tooltip';
import { AlertComponent } from '../../shared/alert/alert.component';
import { FormsModule } from '@angular/forms';
import { NgIf, NgFor, NgClass } from '@angular/common';
import { EditProfileSectionComponent } from '@mdm/modals/edit-profile-section/edit-profile-section.component';

@Component({
selector: 'mdm-edit-profile-modal',
templateUrl: './edit-profile-modal.component.html',
styleUrls: ['./edit-profile-modal.component.scss'],
standalone: true,
imports: [MatDialogTitle, NgIf, MatDialogContent, FormsModule, AlertComponent, NgFor, MatTooltip, ContentEditorComponent, MatInput, NgClass, ExtendedModule, MatButton, MatFormField, MatSelect, MatOption, ModelSelectorTreeComponent, MatError, MatDialogActions]
imports: [MatDialogTitle, NgIf, MatDialogContent, FormsModule, AlertComponent, NgFor, MatTooltip, ContentEditorComponent, MatInput, NgClass, ExtendedModule, MatButton, MatFormField, MatSelect, MatOption, ModelSelectorTreeComponent, MatError, MatDialogActions, EditProfileSectionComponent]
})
export class EditProfileModalComponent implements OnInit {
profileData: Profile;
Expand Down Expand Up @@ -117,7 +118,7 @@ export class EditProfileModalComponent implements OnInit {
) {
field.currentValue = null;
}
else {
else {
field.currentValue = JSON.parse(field.currentValue);
}
}
Expand Down Expand Up @@ -278,7 +279,7 @@ export class EditProfileModalComponent implements OnInit {

private loadDefaultCustomProfile(properties: ApiProperty[]) {
this.showCanEditPropertyAlert = JSON.parse(
this.getContentProperty(properties, this.showCanEditPropertyAlertKey)
this.getContentProperty(properties, this.showCanEditPropertyAlertKey) || 'false'
);
}

Expand Down
Loading
Loading