How to use the lightning/navigation.NavigationMixin function in lightning

To help you get started, we’ve selected a few lightning examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FabienHuot / KnowledgeSearch / force-app / main / default / lwc / knowledgeSearch / knowledgeSearch.js View on Github external
/* eslint-disable no-console */

import { LightningElement, track, wire, api } from 'lwc';

import { NavigationMixin } from 'lightning/navigation';

import KnowledgeRecordTypes from '@salesforce/apex/knowledgeSearchController.KnowledgeRecordTypes';
import KnowledgeArticles from '@salesforce/apex/knowledgeSearchController.KnowledgeArticles';
//import getPicklistValues from '@salesforce/apex/knowledgeSearchLWC.getPicklistValues_old';

export default class KnowledgeSearchLWC extends NavigationMixin(LightningElement) {
    @track article;
    @track articleList = [];


    @track results

    //@track cible = 'Tous';

    @track rt = 'All';
    @track rtList = [];

    @api displayCard;

    get componentClass() {
        return (this.displayCard ? 'slds-page-header' : 'slds-m-around_medium');
    }
github dreamhouseapp / dreamhouse-lwc / force-app / main / default / lwc / brokerCard / brokerCard.js View on Github external
import BROKER_FIELD from '@salesforce/schema/Property__c.Broker__c';
import NAME_FIELD from '@salesforce/schema/Broker__c.Name';
import PHONE_FIELD from '@salesforce/schema/Broker__c.Phone__c';
import MOBILE_PHONE_FIELD from '@salesforce/schema/Broker__c.Mobile_Phone__c';
import EMAIL_FIELD from '@salesforce/schema/Broker__c.Email__c';

const PROPERTY_FIELDS = [BROKER_FIELD];
const BROKER_FIELDS = [
    NAME_FIELD,
    PHONE_FIELD,
    MOBILE_PHONE_FIELD,
    EMAIL_FIELD
];

export default class BrokerCard extends NavigationMixin(LightningElement) {
    @api recordId;

    @track brokerFields = BROKER_FIELDS;

    @wire(getRecord, { recordId: '$recordId', fields: PROPERTY_FIELDS })
    property;

    get brokerId() {
        return getFieldValue(this.property.data, BROKER_FIELD);
    }

    handleNavigateToRecord() {
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: this.brokerId,
github dreamhouseapp / dreamhouse-lwc / force-app / main / default / lwc / propertySummary / propertySummary.js View on Github external
import { LightningElement, api, track, wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import { NavigationMixin } from 'lightning/navigation';
import { registerListener, unregisterAllListeners } from 'c/pubsub';
import NAME_FIELD from '@salesforce/schema/Property__c.Name';
import BED_FIELD from '@salesforce/schema/Property__c.Beds__c';
import BATH_FIELD from '@salesforce/schema/Property__c.Baths__c';
import PRICE_FIELD from '@salesforce/schema/Property__c.Price__c';
import BROKER_FIELD from '@salesforce/schema/Property__c.Broker__c';
import PICTURE_FIELD from '@salesforce/schema/Property__c.Picture__c';

export default class PropertySummary extends NavigationMixin(LightningElement) {
    @api recordId;
    @track propertyFields = [BED_FIELD, BATH_FIELD, PRICE_FIELD, BROKER_FIELD];

    @wire(CurrentPageReference) pageRef;

    @wire(getRecord, {
        recordId: '$recordId',
        fields: [NAME_FIELD, PICTURE_FIELD]
    })
    property;

    get propertyName() {
        return getFieldValue(this.property.data, NAME_FIELD);
    }

    get pictureURL() {