How to use the @microsoft/sp-lodash-subset.cloneDeep function in @microsoft/sp-lodash-subset

To help you get started, we’ve selected a few @microsoft/sp-lodash-subset 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 SharePoint / sp-dev-fx-controls-react / src / controls / listView / ListView.tsx View on Github external
private _updateFilterValue = (filterValue: string) => {
    let items = cloneDeep(this.originalItems);
    let groups = cloneDeep(this.originalGroups);
    const columns = cloneDeep(this.originalColumns);

    // Check if a value is provided, otherwise revert back to the original list of items
    if (filterValue && items && items.length > 0) {
      items = this._executeFiltering(filterValue, items, columns);
      const grouping = this._getGroups(items, this.props.groupByFields);

      // Update grouping
      if (grouping.groups.length > 0) {
        groups = grouping.groups;
        // Update the items
        items = grouping.items;
      } else {
        groups = null;
      }
    }
github SharePoint / sp-dev-fx-controls-react / src / controls / listView / ListView.tsx View on Github external
private _updateFilterValue = (filterValue: string) => {
    let items = cloneDeep(this.originalItems);
    let groups = cloneDeep(this.originalGroups);
    const columns = cloneDeep(this.originalColumns);

    // Check if a value is provided, otherwise revert back to the original list of items
    if (filterValue && items && items.length > 0) {
      items = this._executeFiltering(filterValue, items, columns);
      const grouping = this._getGroups(items, this.props.groupByFields);

      // Update grouping
      if (grouping.groups.length > 0) {
        groups = grouping.groups;
        // Update the items
        items = grouping.items;
      } else {
        groups = null;
      }
github SharePoint / sp-dev-fx-webparts / samples / react-content-query-webpart / src / controls / PropertyPaneQueryFilterPanel / components / QueryFilterPanel / QueryFilterPanel.tsx View on Github external
private onFilterChanged(filter:IQueryFilter): void {
        // Makes sure the parent is not notified for no reason if the modified filter was (and still is) considered empty
        let isWorthNotifyingParent = true;
        let oldFilter = this.state.filters.filter((i) => { return i.index == filter.index; })[0];
        let oldFilterIndex = this.state.filters.indexOf(oldFilter);
        
        if(this.props.trimEmptyFiltersOnChange && this.isFilterEmpty(oldFilter) && this.isFilterEmpty(filter)) {
            isWorthNotifyingParent = false;
        }

        // Updates the modified filter in the state
        this.state.filters[oldFilterIndex] = cloneDeep(filter);
        this.setState((prevState: IQueryFilterPanelState, props: IQueryFilterPanelProps): IQueryFilterPanelState => {
            prevState.filters = this.state.filters;
            return prevState;
        });

        // Notifies the parent with the updated filters
        if(isWorthNotifyingParent) {
            let filters:IQueryFilter[] = this.props.trimEmptyFiltersOnChange ? this.state.filters.filter((f) => { return !this.isFilterEmpty(f); }) : this.state.filters;
            this.props.onChanged(filters);
        }
    }
github SharePoint / sp-dev-fx-property-controls / src / propertyFields / termPicker / PropertyFieldTermPickerHost.tsx View on Github external
private onOpenPanel(): void {
    if (this.props.disabled === true) {
      return;
    }

    // Store the current code value
    this.previousValues = cloneDeep(this.state.activeNodes);
    this.cancel = true;

    this.loadTermStores();

    this.setState({
      openPanel: true,
      loaded: false
    });
  }
github SharePoint / sp-dev-fx-controls-react / src / controls / listView / ListView.tsx View on Github external
private _processProperties() {
    const { items, iconFieldName, viewFields, groupByFields, showFilter } = this.props;

    let tempState: IListViewState = cloneDeep(this.state);
    let columns: IColumn[] = null;
    // Check if a set of items was provided
    if (typeof items !== 'undefined' && items !== null) {
      tempState.items = this._flattenItems(items);
    }

    // Check if an icon needs to be shown
    if (iconFieldName) {
      if (columns === null) { columns = []; }
      const iconColumn = this._createIconColumn(iconFieldName);
      columns.push(iconColumn);
    }

    // Check if view fields were provided
    if (viewFields) {
      if (columns === null) { columns = []; }
github SharePoint / sp-dev-fx-controls-react / src / controls / listView / ListView.tsx View on Github external
private _updateFilterValue = (filterValue: string) => {
    let items = cloneDeep(this.originalItems);
    let groups = cloneDeep(this.originalGroups);
    const columns = cloneDeep(this.originalColumns);

    // Check if a value is provided, otherwise revert back to the original list of items
    if (filterValue && items && items.length > 0) {
      items = this._executeFiltering(filterValue, items, columns);
      const grouping = this._getGroups(items, this.props.groupByFields);

      // Update grouping
      if (grouping.groups.length > 0) {
        groups = grouping.groups;
        // Update the items
        items = grouping.items;
      } else {
        groups = null;
      }
    }
github SharePoint / sp-dev-fx-controls-react / src / services / PeopleSearchService.ts View on Github external
// filter for showHiddenInUI
        filterVal = filterVal ? `${filterVal} and (IsHiddenInUI eq ${showHiddenInUI})` : `?$filter=IsHiddenInUI eq ${showHiddenInUI}`;

        // Create the rest API
        const restApi = `${siteUrl}${stringVal}${filterVal}`;
        const data = await this.context.spHttpClient.get(restApi, SPHttpClient.configurations.v1, {
          headers: {
            'Accept': 'application/json;odata.metadata=none'
          }
        });

        if (data.ok) {
          const userDataResp: IUsers = await data.json();
          if (userDataResp && userDataResp.value && userDataResp.value.length > 0) {
            this.cachedPersonas[cachedPropertyName] = cloneDeep(userDataResp.value);
          }
        }
      }

      // Check if persons or groups were retrieved and return the ones for the query
      if (this.cachedPersonas[cachedPropertyName]) {
        let persons = this.cachedPersonas[cachedPropertyName];
        if (query) {
          // Check if exact match is required
          if (exactMatch) {
            persons = persons.filter(element => element.Email.toLowerCase() === query.toLowerCase() || element.LoginName.toLowerCase() === query.toLowerCase());
          } else {
            persons = persons.filter(element => element.Title.toLowerCase().indexOf(query.toLowerCase()) !== -1 || element.Email.toLowerCase().indexOf(query.toLowerCase()) !== -1 || element.LoginName.toLowerCase().indexOf(query.toLowerCase()) !== -1);
          }
        }