Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fet/demo copy date functionality #988

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
52f8603
start poc work for complicated model ui
nerrad Feb 26, 2019
22bf8fc
started todo so can create pull
nerrad Feb 26, 2019
598deec
add new selectors/actions etc to schema for relation type related que…
nerrad Feb 27, 2019
cee6e50
add new selector for doing efficient relation entity query
nerrad Feb 27, 2019
fc0cb69
Merge branch 'FET/add-relation-type-awareness-to-models-and-stores' i…
nerrad Feb 27, 2019
bd4b877
implement the new selectors and finish off the app
nerrad Feb 27, 2019
113c68a
add demo app demonstrating cloning of a datetime and updating entitti…
nerrad Feb 27, 2019
07134bf
update build files for changes
nerrad Feb 27, 2019
9feb782
fix incorrect arg for dispatch
nerrad Feb 27, 2019
1ddf200
ensure entityId is normalized
nerrad Feb 27, 2019
aeb5d86
fix bugs due to incorrectly prepared strings
nerrad Feb 27, 2019
133897a
make sure we use Immutable.Map and we’re passing the right values on …
nerrad Feb 27, 2019
b7cd561
fix bugs with prepped strings used as args
nerrad Feb 27, 2019
b3407a3
add clone getter to BaseEntity
nerrad Feb 27, 2019
c6c8f01
add `forClone` getter to BaseEntity
nerrad Feb 27, 2019
dc0bb05
add field extractor for fields and values used for cloning
nerrad Feb 27, 2019
3de2213
Merge branch 'FET/add-relation-type-awareness-to-models-and-stores' i…
nerrad Feb 27, 2019
67b4c43
update build files
nerrad Feb 27, 2019
0d82915
started todo so can create pull
nerrad Feb 26, 2019
2b6aa4a
add new selectors/actions etc to schema for relation type related que…
nerrad Feb 27, 2019
f87d64c
add new selector for doing efficient relation entity query
nerrad Feb 27, 2019
e734e81
fix incorrect arg for dispatch
nerrad Feb 27, 2019
9cb2c84
ensure entityId is normalized
nerrad Feb 27, 2019
e3b36ab
fix bugs due to incorrectly prepared strings
nerrad Feb 27, 2019
58574d5
make sure we use Immutable.Map and we’re passing the right values on …
nerrad Feb 27, 2019
a66d3c7
fix bugs with prepped strings used as args
nerrad Feb 27, 2019
1bfd527
add clone getter to BaseEntity
nerrad Feb 27, 2019
649f42e
add `forClone` getter to BaseEntity
nerrad Feb 27, 2019
39aaa6f
add field extractor for fields and values used for cloning
nerrad Feb 27, 2019
23ef477
Fix incorrect arguments
nerrad Feb 28, 2019
6637af0
make sure new clone method is exporting all enumerable properties and…
nerrad Mar 1, 2019
04740ca
Merge branch 'FET/add-relation-type-awareness-to-models-and-stores' i…
nerrad Mar 1, 2019
2a80b4d
minor fixes
nerrad Mar 1, 2019
850d22d
update build files
nerrad Mar 1, 2019
da43bbb
add missing semiColon
nerrad Mar 1, 2019
ed98faa
add missing resolving of getRelatedEntities when creating a relation
nerrad Mar 1, 2019
d15bb2d
handle doing reverse resolution of getRelatedEntities when creating a…
nerrad Mar 1, 2019
f2c9a73
Merge branch 'FET/add-relation-type-awareness-to-models-and-stores' i…
nerrad Mar 1, 2019
479af5c
remove extraneous argument
nerrad Mar 1, 2019
cdb9fed
use state to track initialization instead of props
nerrad Mar 1, 2019
a1cfdb8
update build (dev) files
nerrad Mar 1, 2019
7e6d32d
fix another bug and update existing tests for changes
nerrad Mar 1, 2019
1b64972
add jsdocs and unit-test converage
nerrad Mar 3, 2019
92a733d
add dev docs for new things
nerrad Mar 3, 2019
434b6cc
update tests and fix linting
nerrad Mar 3, 2019
ab1fe3e
update build files
nerrad Mar 4, 2019
ce5b2c2
Merge branch 'FET/add-relation-type-awareness-to-models-and-stores' i…
nerrad Mar 4, 2019
0a05378
update build files
nerrad Mar 4, 2019
b455375
update build files
nerrad Mar 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions admin_pages/events/Events_Admin_Page.core.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use EventEspresso\core\domain\services\assets\CoreAssetManager;

/**
* Events_Admin_Page
* This contains the logic for setting up the Events related pages.
Expand Down Expand Up @@ -229,6 +231,10 @@ protected function _set_page_routes()
'func' => '_category_list_table',
'capability' => 'ee_manage_event_categories',
),
'demo_page' => array(
'func' => 'demoPage',
'capability' => 'administrator',
),
);
}

Expand Down Expand Up @@ -500,6 +506,13 @@ protected function _set_page_config()
'metaboxes' => $this->_default_espresso_metaboxes,
'require_nonce' => false,
),
'demo_page' => array(
'nav' => array(
'label' => esc_html__('Wp Data Demo', 'event_espresso'),
'order' => 50,
),
'require_nonce' => false,
),
);
}

Expand Down Expand Up @@ -601,6 +614,12 @@ public function load_scripts_styles_edit()
wp_enqueue_script('event-datetime-metabox');
}

public function load_scripts_styles_demo_page()
{
wp_enqueue_script(CoreAssetManager::JS_HANDLE_DEMO_APP);
wp_enqueue_style(CoreAssetManager::CSS_HANDLE_DEMO_APP);
}


/**
* Populating the _views property for the category list table view.
Expand Down Expand Up @@ -2679,4 +2698,10 @@ public function save_timezonestring_setting()
$this->_template_args['success'] = true;
$this->_return_json(true, array('action' => 'create_new'));
}

public function demoPage()
{
$this->_template_args['admin_page_content'] = '<div id="main-app"></div>';
$this->display_admin_page_with_no_sidebar();
}
}
10 changes: 6 additions & 4 deletions assets/dist/build-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"components.css": "ee-components.997177945b17ee98a639.dist.css",
"components.js": "ee-components.a695ce319583d44ee305.dist.js",
"data-stores.js": "ee-data-stores.17fa41b8f7e48f188880.dist.js",
"components.js": "ee-components.862d05bcd21aee9a8e46.dist.js",
"data-stores.js": "ee-data-stores.5730d2796de06a3cc59e.dist.js",
"demo-app.css": "ee-demo-app.1d9252864c9f252a2cf7.dist.css",
"demo-app.js": "ee-demo-app.cfc8a6253652f506f46c.dist.js",
"editor-hocs.js": "ee-editor-hocs.15a813aac7a51b5473cb.dist.js",
"eejs.js": "ee-eejs.4bd48b02f85a875e3121.dist.js",
"eventespresso-core-blocks-frontend.css": "ee-eventespresso-core-blocks-frontend.f0ea9ad96d720bc8dc9b.dist.css",
Expand All @@ -11,9 +13,9 @@
"helpers.js": "ee-helpers.68fc060c389a6c79fa44.dist.js",
"hocs.js": "ee-hocs.2c2966004969557c1cf6.dist.js",
"manifest.js": "ee-manifest.45b8faa573682047153a.dist.js",
"model.js": "ee-model.2968981fc37f7c6f807a.dist.js",
"model.js": "ee-model.1c92d31063e9885dfbdd.dist.js",
"validators.js": "ee-validators.a528908a7b9fe1495f98.dist.js",
"valueObjects.js": "ee-valueObjects.0da3d089c063c01f2d4c.dist.js",
"valueObjects.js": "ee-valueObjects.85086c9d7f47d85da410.dist.js",
"vendor.js": "ee-vendor.bd38b3513999b11ec414.dist.js",
"wp-plugins-page.css": "ee-wp-plugins-page.0aa86e25ceb666993965.dist.css",
"wp-plugins-page.js": "ee-wp-plugins-page.affe522f72bae3a5e5df.dist.js"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions assets/dist/ee-demo-app.1d9252864c9f252a2cf7.dist.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5,192 changes: 5,192 additions & 0 deletions assets/dist/ee-demo-app.cfc8a6253652f506f46c.dist.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getIdsFromBaseEntityArray } from '@eventespresso/helpers';
/**
* Internal imports
*/
import { dispatch } from '../../base-controls';
import { dispatch, select, resolveSelect } from '../../base-controls';
import { REDUCER_KEY } from '../constants';

/**
Expand Down Expand Up @@ -46,7 +46,6 @@ function* createRelation(
yield dispatch(
REDUCER_KEY,
'receiveEntityAndResolve',
singularRelationName,
relationEntity
);
yield dispatch(
Expand Down Expand Up @@ -84,6 +83,7 @@ function* createRelations(
) {
relationName = pluralModelName( relationName );
const singularRelationName = singularModelName( relationName );
const pluralRelationName = pluralModelName( relationName );

try {
assertArrayHasEntitiesForModel( relationEntities, singularRelationName );
Expand All @@ -97,7 +97,7 @@ function* createRelations(
);
return;
}
let relationIds = getIdsFromBaseEntityArray( relationEntities );
const relationIds = getIdsFromBaseEntityArray( relationEntities );
yield dispatch(
REDUCER_KEY,
'receiveEntitiesAndResolve',
Expand All @@ -112,17 +112,111 @@ function* createRelations(
relationName,
relationIds,
);
relationIds = [ ...relationIds ];
while ( relationIds.length > 0 ) {
const modelEntity = yield resolveSelect(
REDUCER_KEY,
'getEntityById',
modelName,
entityId,
);
yield dispatch(
'core/data',
'finishResolution',
REDUCER_KEY,
'getRelatedEntities',
[ modelEntity, pluralRelationName ]
);
const relationsToResolve = [ ...relationEntities ];
while ( relationsToResolve.length > 0 ) {
const relationEntity = relationsToResolve.pop();
yield dispatch(
REDUCER_KEY,
'receiveDirtyRelationAddition',
relationName,
relationIds.pop(),
relationEntity.id,
modelName,
entityId,
);
yield dispatch(
'core/data',
'finishResolution',
REDUCER_KEY,
'getRelatedEntities',
[ relationEntity, pluralModelName( modelName ) ]
);
}
}

/**
* This action is used to ensure a relation Entity related to the given
* model entity id is both added to the state and various selectors for these
* are resolved so no additional resolution happens for these.
*
* The purpose for this action is to allow for doing more efficient batch
* queries of entities from an api request and then triggering the resolution of
* any more granular selectors that have resolvers. This basically allows one
* to hydrate the `eventespresso/core` state with more efficient queries.
*
* @param {BaseEntity} relationEntity
* @param {string} modelName
* @param {number|string} modelId
*/
function* resolveRelationRecordForRelation(
relationEntity,
modelName,
modelId
) {
const singularRelationName = singularModelName( relationEntity.modelName );
const pluralRelationName = pluralModelName( relationEntity.modelName );
const hasEntity = yield select(
'core/data',
'hasFinishedResolution',
REDUCER_KEY,
'getEntityById',
[ singularRelationName, relationEntity.id ]
);
relationEntity = hasEntity ?
yield select(
REDUCER_KEY,
'getEntityById',
singularRelationName,
relationEntity.id
) :
relationEntity;
if ( ! hasEntity ) {
yield dispatch(
REDUCER_KEY,
'receiveEntityAndResolve',
relationEntity
);
}
yield dispatch(
REDUCER_KEY,
'receiveRelatedEntities',
modelName,
modelId,
pluralRelationName,
[ relationEntity.id ]
);
const modelEntity = yield resolveSelect(
REDUCER_KEY,
'getEntityById',
modelName,
modelId
);
yield dispatch(
'core/data',
'finishResolution',
REDUCER_KEY,
'getRelatedEntities',
[ modelEntity, pluralRelationName ]
);
yield dispatch(
'core/data',
'finishResolution',
REDUCER_KEY,
'getRelatedEntities',
[ relationEntity, pluralModelName( modelName ) ]
);
}

/**
Expand All @@ -142,4 +236,4 @@ const assertArrayHasEntitiesForModel = ( entities, relationModelName ) => {
}
};

export { createRelation, createRelations };
export { createRelation, createRelations, resolveRelationRecordForRelation };
Loading