Skip to content

Instantly share code, notes, and snippets.

@joshpitzalis
Last active January 29, 2020 08:51
Show Gist options
  • Save joshpitzalis/a5477c28a1c4626b457111af3cfabcfd to your computer and use it in GitHub Desktop.
Save joshpitzalis/a5477c28a1c4626b457111af3cfabcfd to your computer and use it in GitHub Desktop.

Revisions

  1. joshpitzalis revised this gist Jan 29, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion machine.js
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@
    DESELECT_ALL: 'selection_screen',
    ADD_CONTACTS: 'add_contacts_button',
    },
    initial: 'allSelected',
    initial: 'entireSelection',
    states: {
    entireSelection: {
    TOGGLE_FILTER: 'justTheConflicts'
  2. joshpitzalis revised this gist Jan 29, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -27,14 +27,14 @@
    },
    initial: 'allSelected',
    states: {
    allSelected: {
    entireSelection: {
    TOGGLE_FILTER: 'justTheConflicts'
    },
    justTheConflicts: {
    on: {
    SELECTED_FIELD_TO_OVERWRITE:'justTheConflicts',
    SELECTED_FIELD_FOR_ALL_OVERWRITES:'justTheConflicts',
    TOGGLE_FILTER: 'allSelected'
    TOGGLE_FILTER: 'entireSelection'
    }
    },

  3. joshpitzalis revised this gist Jan 29, 2020. 1 changed file with 18 additions and 11 deletions.
    29 changes: 18 additions & 11 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -17,21 +17,28 @@
    }
    },
    selection_screen: {
    onEntry: 'deselectConflicts',
    on: {
    CONTACT_SELECTED: 'selection_screen',
    CONTACT_DESELECTED: 'selection_screen',
    SELECT_ALL: 'selection_screen',
    ADD_CONTACTS: 'conflict_screen'
    }
    },
    conflict_screen: {
    onEntry: 'checkForConflicts',
    on: {
    NO_CONFICTS_DETECTED: 'add_contacts_button',
    MERGED_CONTACT: 'conflict_screen',
    CREATED_FIELD_TO_OVERWRITE:'conflict_screen',
    SELECTED_FIELD_FOR_ALL_OVERWRITES:'conflict_screen',
    }
    DESELECT_ALL: 'selection_screen',
    ADD_CONTACTS: 'add_contacts_button',
    },
    initial: 'allSelected',
    states: {
    allSelected: {
    TOGGLE_FILTER: 'justTheConflicts'
    },
    justTheConflicts: {
    on: {
    SELECTED_FIELD_TO_OVERWRITE:'justTheConflicts',
    SELECTED_FIELD_FOR_ALL_OVERWRITES:'justTheConflicts',
    TOGGLE_FILTER: 'allSelected'
    }
    },

    }
    }
    }
    });
  4. joshpitzalis revised this gist Jan 28, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -28,9 +28,9 @@
    onEntry: 'checkForConflicts',
    on: {
    NO_CONFICTS_DETECTED: 'add_contacts_button',
    MERGED_CONTACTS: 'conflict_screen',
    MERGED_CONTACT: 'conflict_screen',
    CREATED_FIELD_TO_OVERWRITE:'conflict_screen',
    SELECTED_FIELD_FOR_ALL_OVERWRITES:'conflict_screen',
    SELECTED_FIELD_FOR_ALL_OVERWRITES:'conflict_screen',
    }
    }
    }
  5. joshpitzalis revised this gist Jan 28, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion machine.js
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@
    on: {
    NO_CONFICTS_DETECTED: 'add_contacts_button',
    MERGED_CONTACTS: 'conflict_screen',
    CREATEDED_FIELD_TO_OVERWRITE:'conflict_screen',
    CREATED_FIELD_TO_OVERWRITE:'conflict_screen',
    SELECTED_FIELD_FOR_ALL_OVERWRITES:'conflict_screen',
    }
    }
  6. joshpitzalis revised this gist Jan 28, 2020. 1 changed file with 17 additions and 17 deletions.
    34 changes: 17 additions & 17 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -2,37 +2,37 @@

    const fetchMachine = Machine({
    id: 'contacts',
    initial: 'idle',
    initial: 'add_contacts_button',

    states: {
    idle: {
    add_contacts_button: {
    on: {
    ADDED: 'permissions'
    ADDED: 'permission_screen'
    }
    },
    permissions: {
    permission_screen: {
    on: {
    APPROVED: 'select',
    REJECTED: 'idle'
    APPROVED: 'selection_screen',
    REJECTED: 'add_contacts_button'
    }
    },
    select: {
    selection_screen: {
    on: {
    CONTACT_SELECTED: 'select',
    CONTACT_DESELECTED: 'select',
    SELECT_ALL: 'select',
    ADD_CONTACTS: 'conflict'
    CONTACT_SELECTED: 'selection_screen',
    CONTACT_DESELECTED: 'selection_screen',
    SELECT_ALL: 'selection_screen',
    ADD_CONTACTS: 'conflict_screen'
    }
    },
    conflict: {
    conflict_screen: {
    onEntry: 'checkForConflicts',
    on: {
    NO_CONFICTS: 'contactAdded',
    MERGE_CONTACTS: 'conflict',
    CREATE_SEPERATE_CONTACTS: 'conflict'
    NO_CONFICTS_DETECTED: 'add_contacts_button',
    MERGED_CONTACTS: 'conflict_screen',
    CREATEDED_FIELD_TO_OVERWRITE:'conflict_screen',
    SELECTED_FIELD_FOR_ALL_OVERWRITES:'conflict_screen',
    }
    },
    contactAdded: { type: 'final'}
    }
    }
    });

  7. joshpitzalis created this gist Jan 27, 2020.
    38 changes: 38 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@


    const fetchMachine = Machine({
    id: 'contacts',
    initial: 'idle',

    states: {
    idle: {
    on: {
    ADDED: 'permissions'
    }
    },
    permissions: {
    on: {
    APPROVED: 'select',
    REJECTED: 'idle'
    }
    },
    select: {
    on: {
    CONTACT_SELECTED: 'select',
    CONTACT_DESELECTED: 'select',
    SELECT_ALL: 'select',
    ADD_CONTACTS: 'conflict'
    }
    },
    conflict: {
    onEntry: 'checkForConflicts',
    on: {
    NO_CONFICTS: 'contactAdded',
    MERGE_CONTACTS: 'conflict',
    CREATE_SEPERATE_CONTACTS: 'conflict'
    }
    },
    contactAdded: { type: 'final'}
    }
    });