Skip to content

Commit

Permalink
Merge branch 'project/admin-refactor' of https://github.com/CalderaWP…
Browse files Browse the repository at this point in the history
…/caldera-forms into project/admin-refactor

* 'project/admin-refactor' of https://github.com/CalderaWP/caldera-forms:
  hacky solution to avoid loading old assets in admin
  #2445 Hi roy commit for new admin app
  #2445 restart admin client

# Conflicts:
#	package.json
#	vendor/autoload.php
#	vendor/calderawp/caldera-containers/.travis.yml
#	vendor/calderawp/caldera-containers/README.MD
#	vendor/calderawp/caldera-containers/Tests/ServiceServiceContainerTest.php
#	vendor/calderawp/caldera-containers/composer.json
#	vendor/calderawp/caldera-containers/src/Service/Container.php
#	vendor/calderawp/caldera-forms-query
#	vendor/composer/autoload_classmap.php
#	vendor/composer/autoload_real.php
#	vendor/composer/autoload_static.php
#	vendor/composer/installed.json
  • Loading branch information
Josh Pollock committed Aug 22, 2018
2 parents 5fc75d4 + c56d342 commit 793e801
Show file tree
Hide file tree
Showing 42 changed files with 43,640 additions and 20,420 deletions.
16 changes: 6 additions & 10 deletions classes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ private function __construct() {
add_filter('caldera_forms_get_panel_extensions', array( $this, 'get_panel_extensions'), 1);
add_filter('caldera_forms_entry_viewer_buttons', array( $this, 'set_viewer_buttons'),10, 4);
add_filter('caldera_forms_entry_editor_buttons', array( $this, 'set_editor_buttons'),10, 4);


// action

add_action('caldera_forms_admin_templates', array( $this, 'get_admin_templates'),1);
add_action('caldera_forms_entry_meta_templates', array( $this, 'get_admin_meta_templates'),1);

add_action( 'init', array( $this, 'save_form') );
Expand Down Expand Up @@ -1218,15 +1216,13 @@ public function enqueue_admin_stylescripts() {

} else {

Caldera_Forms_Render_Assets::enqueue_all_fields();

if ( ! self::is_main_page() ) {
Caldera_Forms_Render_Assets::enqueue_all_fields();
}

if ( ! empty( $_GET[ 'edit-entry' ] ) ) {
if ( ! empty( $_GET[ 'edit-entry' ] ) ) {
Caldera_Forms_Render_Assets::enqueue_style( 'grid' );
}else{
$clippy = new Caldera_Forms_Admin_Clippy( $this->plugin_slug, site_url() );
$clippy->assets();
}
}
}

Caldera_Forms_Admin_Assets::panels();
Expand Down
61 changes: 47 additions & 14 deletions classes/admin/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,39 @@ public static function form_editor(){
*
* @since 1.5.0
*/
public static function admin_common(){
public static function admin_common( ){
self::maybe_register_all_admin();
Caldera_Forms_Render_Assets::maybe_register();
Caldera_Forms_Render_Assets::enqueue_script( 'validator' );
$locale = get_locale();
if( $locale !== 'en_US' ){
Caldera_Forms_Render_Assets::enqueue_validator_i18n();
}
$is_main_admin = true !== Caldera_Forms_Admin::is_main_page();
if( $is_main_admin ) {
Caldera_Forms_Render_Assets::enqueue_script('validator');
$locale = get_locale();
if ($locale !== 'en_US') {
Caldera_Forms_Render_Assets::enqueue_validator_i18n();
}
Caldera_Forms_Render_Assets::enqueue_style( 'grid' );

}

Caldera_Forms_Render_Assets::enqueue_style( 'grid' );
self::enqueue_style( 'admin' );
$slug = self::slug( 'admin' );
self::set_cf_admin($slug);
$slug = self::main_admin_asset_slug();
self::set_cf_admin($slug);
self::enqueue_script( 'admin' );

if( $is_main_admin ){
self::enqueue_style( 'modal' );
Caldera_Forms_Render_Assets::enqueue_style( 'front' );
Caldera_Forms_Render_Assets::enqueue_style( 'field' );

self::enqueue_script( 'baldrick' );
}

self::enqueue_style( 'modal' );
self::enqueue_script( 'admin' );
Caldera_Forms_Render_Assets::enqueue_style( 'front' );
Caldera_Forms_Render_Assets::enqueue_style( 'field' );

self::enqueue_script( 'baldrick' );

}



/**
* Register all scripts for Caldera Forms admin
*
Expand Down Expand Up @@ -162,6 +172,11 @@ public static function register_styles(){
* @param string $slug Style slug
*/
public static function enqueue_style( $slug ){
if( $slug === self::main_admin_asset_slug() || Caldera_Forms_Render_Assets::is_client_entry_point( $slug ) ){

wp_enqueue_style(self::main_admin_asset_slug());
return;
}
if( 1 !== strpos( $slug, Caldera_Forms::PLUGIN_SLUG ) ){
$slug = self::slug( $slug, false );
}
Expand All @@ -177,6 +192,11 @@ public static function enqueue_style( $slug ){
* @param string $slug Script slug
*/
public static function enqueue_script( $slug ){
if( $slug === self::main_admin_asset_slug() || 'admin' === $slug ){
wp_enqueue_script( self::main_admin_asset_slug() );
return;
}

if( 1 !== strpos( $slug, Caldera_Forms::PLUGIN_SLUG ) ){
$slug = self::slug( $slug, true );
}
Expand Down Expand Up @@ -329,4 +349,17 @@ public static function set_cf_admin($slug) {
wp_localize_script($slug, 'CF_ADMIN', $data);
}

/**
* Get the slug form main admin page assets
*
* @since 1.8.0
*
* @return string
*/
public static function main_admin_asset_slug()
{
$slug = self::slug('admin');
return $slug;
}

}
11 changes: 9 additions & 2 deletions classes/render/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ public static function get_core_scripts(){
'blocks' => self::make_url( 'blocks'),
'editor' => self::make_url( 'editor' ),
'pro' => self::make_url( 'pro' ),
'privacy' => self::make_url( 'privacy' )
'privacy' => self::make_url( 'privacy' ),
'admin' => Caldera_Forms_Admin_Assets::main_admin_asset_slug(),
);

$script_urls[ 'fields' ] = $script_urls[ 'privacy' ];
Expand Down Expand Up @@ -555,7 +556,13 @@ public static function make_url( $name, $script = true ){
* @return bool
*/
public static function is_client_entry_point( $slug ){
return in_array( $slug, array( 'blocks', 'pro', 'privacy' ) );
return in_array( $slug, [
'blocks',
'pro',
'privacy',
'admin',
Caldera_Forms_Admin_Assets::main_admin_asset_slug()
]);
}

/**
Expand Down
15 changes: 0 additions & 15 deletions clients/admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,4 @@
# Caldera Forms Admin Main Page Client


## Views
## AdminRight
This is the three boxes on the left.

## Plan
* Step 1: Setup router and views
** Top bar will be the navigation
** Initial views: AdminLeft (Forms), AdminRight(entries (old or new?)), GlobalSettings.

* Step 2: Make forms view (only thing in AdminLeft right now)
* Step 3 Profit
* Step 4: Make GlobalSettings view
* Step 5: Make old entry viewer work.
* Step 6: Make new entry viewer work.
* Step 7: Merge in pro UI?
* Step 8: Mount the doc search component
43 changes: 0 additions & 43 deletions clients/admin/Views/AdminRight.vue

This file was deleted.

Loading

0 comments on commit 793e801

Please sign in to comment.