Support open in new tab
This commit is contained in:
parent
e739f8b4a0
commit
393b4c5dd3
@ -28,7 +28,7 @@
|
||||
|
||||
<ng-template #resultItemTemplate let-item="item" let-nameProp="nameProp" let-type="type" let-icon="icon" let-date="date">
|
||||
<div #resultItem ngbDropdownItem class="py-2 d-flex align-items-center focus-ring border-0 cursor-pointer" tabindex="-1"
|
||||
(click)="primaryAction(type, item)"
|
||||
(click)="primaryAction(type, item, $event)"
|
||||
(mouseenter)="onItemHover($event)">
|
||||
<i-bs width="1.2em" height="1.2em" name="{{icon}}" class="me-2 text-muted"></i-bs>
|
||||
<div class="text-truncate">
|
||||
@ -39,7 +39,7 @@
|
||||
</div>
|
||||
<div class="btn-group ms-auto">
|
||||
<button #primaryButton type="button" class="btn btn-sm btn-outline-primary d-flex"
|
||||
(click)="primaryAction(type, item); $event.stopImmediatePropagation()"
|
||||
(click)="primaryAction(type, item, $event); $event.stopImmediatePropagation()"
|
||||
(keydown)="onButtonKeyDown($event)"
|
||||
[disabled]="disablePrimaryButton(type, item)"
|
||||
(mouseenter)="onButtonHover($event)">
|
||||
@ -59,7 +59,7 @@
|
||||
</button>
|
||||
@if (type !== DataType.SavedView && type !== DataType.Workflow && type !== DataType.CustomField && type !== DataType.Group && type !== DataType.User && type !== DataType.MailAccount && type !== DataType.MailRule) {
|
||||
<button #secondaryButton type="button" class="btn btn-sm btn-outline-primary d-flex"
|
||||
(click)="secondaryAction(type, item); $event.stopImmediatePropagation()"
|
||||
(click)="secondaryAction(type, item, $event); $event.stopImmediatePropagation()"
|
||||
(keydown)="onButtonKeyDown($event)"
|
||||
[disabled]="disableSecondaryButton(type, item)"
|
||||
(mouseenter)="onButtonHover($event)">
|
||||
|
@ -41,6 +41,7 @@ import { TagEditDialogComponent } from '../../common/edit-dialog/tag-edit-dialog
|
||||
import { UserEditDialogComponent } from '../../common/edit-dialog/user-edit-dialog/user-edit-dialog.component'
|
||||
import { WorkflowEditDialogComponent } from '../../common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component'
|
||||
import { HotKeyService } from 'src/app/services/hot-key.service'
|
||||
import { queryParamsFromFilterRules } from 'src/app/utils/query-params'
|
||||
|
||||
@Component({
|
||||
selector: 'pngx-global-search',
|
||||
@ -104,17 +105,22 @@ export class GlobalSearchComponent implements OnInit {
|
||||
})
|
||||
}
|
||||
|
||||
public primaryAction(type: string, object: ObjectWithId) {
|
||||
public primaryAction(
|
||||
type: string,
|
||||
object: ObjectWithId,
|
||||
event: PointerEvent = null
|
||||
) {
|
||||
const newWindow = event?.metaKey || event?.ctrlKey
|
||||
this.reset(true)
|
||||
let filterRuleType: number
|
||||
let editDialogComponent: any
|
||||
let size: string = 'md'
|
||||
switch (type) {
|
||||
case DataType.Document:
|
||||
this.router.navigate(['/documents', object.id])
|
||||
this.navigateOrOpenInNewWindow(['/documents', object.id], newWindow)
|
||||
return
|
||||
case DataType.SavedView:
|
||||
this.router.navigate(['/view', object.id])
|
||||
this.navigateOrOpenInNewWindow(['/view', object.id], newWindow)
|
||||
return
|
||||
case DataType.Correspondent:
|
||||
filterRuleType = FILTER_HAS_CORRESPONDENT_ANY
|
||||
@ -154,9 +160,10 @@ export class GlobalSearchComponent implements OnInit {
|
||||
}
|
||||
|
||||
if (filterRuleType) {
|
||||
this.documentListViewService.quickFilter([
|
||||
let params = queryParamsFromFilterRules([
|
||||
{ rule_type: filterRuleType, value: object.id.toString() },
|
||||
])
|
||||
this.navigateOrOpenInNewWindow(['/documents', params], newWindow)
|
||||
} else if (editDialogComponent) {
|
||||
const modalRef: NgbModalRef = this.modalService.open(
|
||||
editDialogComponent,
|
||||
@ -325,6 +332,9 @@ export class GlobalSearchComponent implements OnInit {
|
||||
}
|
||||
|
||||
onButtonKeyDown(event: KeyboardEvent) {
|
||||
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
|
||||
event.target.dispatchEvent(new MouseEvent('click', { ctrlKey: true }))
|
||||
}
|
||||
// prevents ngBootstrap issue with keydown events
|
||||
if (
|
||||
!['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft', 'Escape'].includes(
|
||||
@ -370,10 +380,19 @@ export class GlobalSearchComponent implements OnInit {
|
||||
)
|
||||
}
|
||||
|
||||
runAdvanedSearch() {
|
||||
public runAdvanedSearch() {
|
||||
this.documentListViewService.quickFilter([
|
||||
{ rule_type: FILTER_FULLTEXT_QUERY, value: this.query },
|
||||
])
|
||||
this.reset(true)
|
||||
}
|
||||
|
||||
private navigateOrOpenInNewWindow(commands: any, newWindow: boolean = false) {
|
||||
if (newWindow) {
|
||||
const url = this.router.serializeUrl(this.router.createUrlTree(commands))
|
||||
window.open(url, '_blank')
|
||||
} else {
|
||||
this.router.navigate(commands)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user