millayr commented on a change in pull request #906: Toolbar redesign for all 
docs
URL: https://github.com/apache/couchdb-fauxton/pull/906#discussion_r122740914
 
 

 ##########
 File path: app/addons/documents/index-results/apis/base-api.js
 ##########
 @@ -0,0 +1,95 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy 
of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+import ActionTypes from '../actiontypes';
+
+export const nowLoading = () => {
+  return {
+    type: ActionTypes.INDEX_RESULTS_REDUX_IS_LOADING
+  };
+};
+
+export const resetState = () => {
+  return {
+    type: ActionTypes.INDEX_RESULTS_REDUX_RESET_STATE
+  };
+};
+
+export const newResultsAvailable = (docs, params, canShowNext) => {
+  return {
+    type: ActionTypes.INDEX_RESULTS_REDUX_NEW_RESULTS,
+    docs: docs,
+    params: params,
+    canShowNext: canShowNext
+  };
+};
+
+export const newSelectedDocs = (selectedDocs = []) => {
+  return {
+    type: ActionTypes.INDEX_RESULTS_REDUX_NEW_SELECTED_DOCS,
+    selectedDocs: selectedDocs
+  };
+};
+
+export const selectDoc = (doc, selectedDocs) => {
+  const indexInSelectedDocs = selectedDocs.findIndex((selectedDoc) => {
+    return selectedDoc._id === doc._id;
+  });
+
+  if (indexInSelectedDocs > -1) {
+    selectedDocs.splice(indexInSelectedDocs, 1);
+  } else {
+    doc._deleted = true;
+    selectedDocs.push(doc);
+  }
+
+  return newSelectedDocs(selectedDocs);
+};
+
+export const bulkCheckOrUncheck = (docs, selectedDocs, allDocumentsSelected) 
=> {
 
 Review comment:
   Pagination makes this tricky.  When you bulk select all docs on the page, we 
add those docs to the running `selectedDocs` array.  When you bulk deselect all 
docs on the page, we remove them BUT we keep all of the docs you've selected on 
previous pages of results.  So it's not really an all-or-nothing thing.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to