Skip to content

Commit

Permalink
react
Browse files Browse the repository at this point in the history
  • Loading branch information
MeiKatz committed Aug 31, 2020
1 parent 1407c40 commit 0ebb30d
Show file tree
Hide file tree
Showing 4 changed files with 428 additions and 3 deletions.
2 changes: 1 addition & 1 deletion interface/edit-group.php
Expand Up @@ -43,7 +43,7 @@
<input id="edit-group-name" type="text" value="<?php echo $group->name(); ?>" />
</div>
</div>
<?php include "group-permissions.php"; ?>
<div id="group-permissions-editor">Editor wird geladen ...</div>
</div>
<div id="postbox-container-1" class="postbox-container side">
<?php
Expand Down
352 changes: 352 additions & 0 deletions js/secdor-app.js

Large diffs are not rendered by default.

66 changes: 64 additions & 2 deletions src/class-groups-admin-ajax.php
Expand Up @@ -68,6 +68,66 @@ public static function register_hooks() {
"can_move",
)
);

add_action(
"wp_ajax_secdor-editor-panels",
array(
__CLASS__,
"editor_panels",
)
);
}

public static function editor_panels() {
self::assert_ajax();

$group = self::get_current_group();
$post_types = Section_Editing_Plugin::get_supported_post_types();

$panels = array_map(function ( $post_type ) use ( $group ) {
$posts = get_pages(array(
"post_type" => $post_type->name,
));

$menu_icon = $post_type->menu_icon;

if ( ! $menu_icon || substr( $menu_icon, 0, 5 ) === "data:" ) {
// maybe add support for custom icons
// @todo: find out how to colorize custom icons
// in svg + base64
$menu_icon = "dashicons-admin-post";
}

$reduced_posts = array_map(function ($post) use ( $group, $post_type ) {
return array(
"id" => $post->ID,
"label" => $post->post_title,
"parent_id" => $post->post_parent,
"checked" => $group->can_edit( $post ),
//"post_type" => $post_type->name,
);
}, $posts);

/*
return array(
"id" => $post_type->name,
"icon" => $menu_icon,
"posts" => $reduced_posts,
"display_as" => (
$post_type->hierarchical
? "tree"
: "list"
),
);*/

return array($post_type->name, $menu_icon);
}, $post_types);

return self::send_json(
WP_Http::OK,
$panels
);
}

public static function handle_users_autocomplete() {
Expand Down Expand Up @@ -440,8 +500,10 @@ private static function send_json(
$status_code,
$data = null
) {
header( "Content-Type: application/json" );
http_response_code( $status_code );
if ( ! headers_sent() ) {
header( "Content-Type: application/json" );
http_response_code( $status_code );
}

echo json_encode( $data );

Expand Down
11 changes: 11 additions & 0 deletions src/class-groups-admin.php
Expand Up @@ -446,6 +446,17 @@ public static function admin_scripts( $hook ) {
true
);

wp_enqueue_script(
"secdor-app",
plugins_url(
"/js/secdor-app.js",
SECDOR_PLUGIN_ENTRYPOINT
),
array(),
$version,
true
);

wp_localize_script( 'group-editor', 'secdor_group_editor_settings', array_merge( array( 'pluginUrl' => plugins_url( "", SECDOR_PLUGIN_ENTRYPOINT ) ), self::group_editor_i10n() ) );

// Hierarchical permissions editor script
Expand Down

0 comments on commit 0ebb30d

Please sign in to comment.