How to use the @microsoft/sp-lodash-subset.sortBy 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-property-controls / src / propertyFields / collectionData / collectionDataViewer / CollectionDataViewer.tsx View on Github external
public componentDidMount(): void {
    let crntItems = this.props.value ? sortBy(cloneDeep(this.props.value), this.SORT_IDX) : [];
    crntItems = crntItems.map((item, idx) => {
      if (!item[this.SORT_IDX]) {
        item[this.SORT_IDX] = idx + 1;
      }
      return item;
    });
    // Update the sort propety
    crntItems = this.updateSortProperty(crntItems);
    this.setState({
      crntItems: sortBy(crntItems, this.SORT_IDX)
    });
  }
github SharePoint / sp-dev-fx-property-controls / src / propertyFields / termPicker / PropertyFieldTermPickerHost.tsx View on Github external
// Check if it is allowed to select multiple terms
      if (this.props.allowMultipleSelections) {
        // Add the checked term
        activeNodes.push(termItem);
        // Filter out the duplicate terms
        activeNodes = uniqBy(activeNodes, 'key');
      } else {
        // Only store the current selected item
        activeNodes = [termItem];
      }
    } else {
      // Remove the term from the list of active nodes
      activeNodes = activeNodes.filter(item => item.key !== term.Id);
    }
    // Sort all active nodes
    activeNodes = sortBy(activeNodes, 'path');
    // Update the current state
    this.setState({
      activeNodes: activeNodes
    });
  }
github SharePoint / sp-dev-fx-property-controls / src / propertyFields / collectionData / collectionDataViewer / CollectionDataViewer.tsx View on Github external
this.setState((prevState: ICollectionDataViewerState): ICollectionDataViewerState => {
      let { crntItems } = prevState;
      crntItems.splice(idx, 1);

      // Update the sort propety
      crntItems = this.updateSortProperty(crntItems);

      return {
        crntItems: sortBy(crntItems, this.SORT_IDX)
      };
    });
  }
github SharePoint / sp-dev-fx-property-controls / src / propertyFields / collectionData / collectionDataViewer / CollectionDataViewer.tsx View on Github external
public componentDidMount(): void {
    let crntItems = this.props.value ? sortBy(cloneDeep(this.props.value), this.SORT_IDX) : [];
    crntItems = crntItems.map((item, idx) => {
      if (!item[this.SORT_IDX]) {
        item[this.SORT_IDX] = idx + 1;
      }
      return item;
    });
    // Update the sort propety
    crntItems = this.updateSortProperty(crntItems);
    this.setState({
      crntItems: sortBy(crntItems, this.SORT_IDX)
    });
  }
github SharePoint / sp-dev-fx-controls-react / src / controls / taxonomyPicker / TaxonomyPicker.tsx View on Github external
// Check if it is allowed to select multiple terms
      if (this.props.allowMultipleSelections) {
        // Add the checked term
        activeNodes.push(termItem);
        // Filter out the duplicate terms
        activeNodes = uniqBy(activeNodes, 'key');
      } else {
        // Only store the current selected item
        activeNodes = [termItem];
      }
    } else {
      // Remove the term from the list of active nodes
      activeNodes = activeNodes.filter(item => item.key !== term.Id);
    }
    // Sort all active nodes
    activeNodes = sortBy(activeNodes, 'path');
    // Update the current state
    this.setState({
      activeNodes: activeNodes
    });
  }
github SharePoint / sp-dev-fx-webparts / samples / react-search-refiners / spfx / src / services / SearchService / SearchService.ts View on Github external
Title: result.Title,
                                    Url: result.Url,
                                    Description: result.Description
                                } as IPromotedResult);
                            });
                        }                        
                    });

                    results.PromotedResults = promotedResults;
                }

                // Resolve all the promises once to get news
                const relevantResults: ISearchResult[] = await Promise.all(allItemsPromises);

                // Sort refiners according to the property pane value
                refinementResults = sortBy(refinementResults, (refinement) => {

                    // Get the index of the corresponding filter name
                    return sortedRefiners.indexOf(refinement.FilterName);
                });

                results.RelevantResults = relevantResults;
                results.RefinementResults = refinementResults;
                results.TotalRows = this._initialSearchResult.TotalRows;
            }
            return results;

        } catch (error) {
            Logger.write('[SharePointDataProvider.search()]: Error: ' + error, LogLevel.Error);
            throw error;
        }
    }
github SharePoint / sp-dev-fx-controls-react / src / controls / listView / ListView.tsx View on Github external
private _sortItems(items: any[], columnName: string, descending = false): any[] {
    // Sort the items
    const ascItems = sortBy(items, [columnName]);
    const sortedItems = descending ? ascItems.reverse() : ascItems;

    // Check if selection needs to be updated
    if (this._selection) {
      const selection = this._selection.getSelection();
      if (selection && selection.length > 0) {
        // Clear selection
        this._selection.setItems([], true);
        setTimeout(() => {
          // Find new index
          let idxs: number[] = selection.map(item => findIndex(sortedItems, item));
          idxs.forEach(idx => this._selection.setIndexSelected(idx, true, false));
        }, 0);
      }
    }
github SharePoint / sp-dev-fx-property-controls / src / propertyFields / collectionData / collectionDataItem / CollectionDataItem.tsx View on Github external
}

      // If required and message are false, it doesn't need to be added
      if (!fieldMsg.message && !fieldMsg.isRequired) {
        // Remove the item
        if (fieldMsgIdx !== -1) {
          errorMsgs.splice(fieldMsgIdx, 1);
        }
      } else {
        if (fieldMsgIdx === -1) {
          errorMsgs.push(fieldMsg);
        }
      }

      // Sort based on the index
      errorMsgs = sortBy(errorMsgs, ["field"]);

      return {
        errorMsgs
      };
    });
  }
github SharePoint / sp-dev-fx-property-controls / src / propertyFields / collectionData / collectionDataViewer / CollectionDataViewer.tsx View on Github external
this.setState((prevState: ICollectionDataViewerState) => {
      const { crntItems } = prevState;
      let newOrderedItems = cloneDeep(crntItems);
      newOrderedItems = this.moveItemTo(newOrderedItems, oldIdx, newIdx - 1);
      newOrderedItems = this.updateSortProperty(newOrderedItems);
      newOrderedItems = sortBy(newOrderedItems, this.SORT_IDX);

      return {
        crntItems: newOrderedItems
      };
    });
  }