Skip to content

Commit

Permalink
fix: sort models after loading next page in model compose (#659)
Browse files Browse the repository at this point in the history
* fix: sort models after loading next page in model compose

* refactor: update readme
  • Loading branch information
stew-ro authored Oct 21, 2020
1 parent 66b0330 commit 9818d63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ Click on the Analyze icon on the left pane to open the Analyze page. Upload a fo

Tip: You can also run the Analyze API with a REST call. To learn how to do this, see [Train with labels using Python](https://docs.microsoft.com/en-us/azure/cognitive-services/form-recognizer/quickstarts/python-labeled-data).

#### Compose a model ####
Click the Compose icon on the left pane to open the Compose page. FoTT will display the first page of your models—by decending order of Model ID—in a list. Select multiple models you want to compose into one model and click the **Compose** button. Once the new model has been composed, it's ready to analyze with.

![alt text](docs/images/compose.png "Compose")

To load more of your models, click the **Load next page** button at the bottom of the list. This will load the next page of your models by decending order of model ID.

You can sort the currently loaded models by clicking the column headers at the top of the list. Only the currently loaded models will be sorted. You will need to load all pages of your models first and then sort to view the complete sorted list of your models.

#### Save a project and resume later ####

To resume your project at another time or in another browser, you need to save your project's security token and reenter it later.
Expand Down
Binary file added docs/images/compose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 6 additions & 11 deletions src/react/components/pages/modelCompose/modelCompose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -489,18 +489,13 @@ export default class ModelComposePage extends React.Component<IModelComposePageP

let nextPageList = nextPage.nextList;
nextPageList = nextPageList.filter((model) => recentModelIds.indexOf(model.modelId) === -1);
const newList = currentList.concat(nextPageList);

this.allModels = newList;
const newCols = this.state.columns;
newCols.forEach((ncol) => {
ncol.isSorted = false;
ncol.isSortedDescending = true;
});
const appendedList = currentList.concat(nextPageList);
const currerntlySortedColumn: IColumn = this.state.columns.find((column) => column.isSorted);
const appendedAndSortedList = this.copyAndSort(appendedList, currerntlySortedColumn.fieldName!, currerntlySortedColumn.isSortedDescending);
this.allModels = appendedAndSortedList;
this.setState({
modelList: newList,
modelList: appendedAndSortedList,
nextLink: nextPage.nextLink,
columns: newCols,
}, () => {
this.setState({
isLoading: false,
Expand Down Expand Up @@ -557,7 +552,7 @@ export default class ModelComposePage extends React.Component<IModelComposePageP
private handleColumnClick = (event: React.MouseEvent<HTMLElement>, column: IColumn): void => {
const {columns, modelList} = this.state;
const newColumns: IColumn[] = columns.slice();
const currColumn: IColumn = newColumns.filter((col) => column.key === col.key)[0];
const currColumn: IColumn = newColumns.find((col) => column.key === col.key);
newColumns.forEach((newCol: IColumn) => {
if (newCol === currColumn) {
currColumn.isSortedDescending = !currColumn.isSortedDescending;
Expand Down

0 comments on commit 9818d63

Please sign in to comment.