Skip to content

Commit

Permalink
Metrics: Refactor the menu (#2535)
Browse files Browse the repository at this point in the history
* Initial refactoring of metrics menu

* Refactor

* rename logs to activity logs

---------

Co-authored-by: corsac <[email protected]>
  • Loading branch information
kodinkat and corsacca authored Oct 4, 2024
1 parent 7aac101 commit 3f7318d
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 50 deletions.
2 changes: 1 addition & 1 deletion dt-metrics/combined/critical-path.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DT_Metrics_Critical_Path_Chart extends DT_Metrics_Chart_Base
{

//slug and title of the top menu folder
public $base_slug = 'combined'; // lowercase
public $base_slug = 'access'; // lowercase
public $base_title;
public $title;
public $slug = 'critical_path'; // lowercase
Expand Down
2 changes: 1 addition & 1 deletion dt-metrics/combined/daily-activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class DT_Metrics_Daily_Activity extends DT_Metrics_Chart_Base {

//slug and title of the top menu folder
public $base_slug = 'combined'; // lowercase
public $base_slug = 'records'; // lowercase
public $base_title;
public $title;
public $slug = 'daily-activity'; // lowercase
Expand Down
6 changes: 3 additions & 3 deletions dt-metrics/combined/hover-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DT_Metrics_Hover_Map extends DT_Metrics_Chart_Base
{

//slug and title of the top menu folder
public $base_slug = 'combined'; // lowercase
public $base_slug = 'records'; // lowercase
public $base_title;
public $title;
public $slug = 'hover_map'; // lowercase
Expand All @@ -22,7 +22,7 @@ public function __construct() {
if ( !$this->has_permission() ){
return;
}
$this->title = __( 'Hover Map', 'disciple_tools' );
$this->title = __( 'Simple Map', 'disciple_tools' );
$this->base_title = __( 'Project', 'disciple_tools' );

$this->namespace = "dt-metrics/$this->base_slug/$this->slug";
Expand Down Expand Up @@ -62,7 +62,7 @@ public function scripts() {
'current_user_login' => wp_get_current_user()->user_login,
'current_user_id' => get_current_user_id(),
'translations' => [
'title' => __( 'Hover Map', 'disciple_tools' )
'title' => __( 'Simple Map', 'disciple_tools' )
]
]
);
Expand Down
2 changes: 1 addition & 1 deletion dt-metrics/combined/locations-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DT_Metrics_Locations_List extends DT_Metrics_Chart_Base
{

//slug and title of the top menu folder
public $base_slug = 'combined'; // lowercase
public $base_slug = 'records'; // lowercase
public $base_title;
public $title;
public $slug = 'locations_list'; // lowercase
Expand Down
2 changes: 1 addition & 1 deletion dt-metrics/combined/mapbox-maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DT_Metrics_Mapbox_Combined_Maps extends DT_Metrics_Chart_Base
{

//slug and title of the top menu folder
public $base_slug = 'combined'; // lowercase
public $base_slug = 'records'; // lowercase
public $base_title;

public $title;
Expand Down
4 changes: 2 additions & 2 deletions dt-metrics/combined/site-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class DT_Metrics_Site_Links extends DT_Metrics_Chart_Base {

//slug and title of the top menu folder
public $base_slug = 'combined'; // lowercase
public $base_slug = 'access'; // lowercase
public $base_title;
public $title;
public $slug = 'site-links'; // lowercase
Expand All @@ -20,7 +20,7 @@ public function __construct() {
return;
}
$this->title = __( 'Transferred Contacts', 'disciple_tools' );
$this->base_title = __( 'Project', 'disciple_tools' );
$this->base_title = __( 'Access', 'disciple_tools' );

$url_path = dt_get_url_path( true );
if ( "metrics/$this->base_slug/$this->slug" === $url_path ) {
Expand Down
4 changes: 2 additions & 2 deletions dt-metrics/contacts/sources.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DT_Metrics_Sources_Chart extends DT_Metrics_Chart_Base
{

//slug and title of the top menu folder
public $base_slug = 'contacts'; // lowercase
public $base_slug = 'access'; // lowercase
public $base_title;
public $title;
public $slug = 'sources'; // lowercase
Expand All @@ -22,7 +22,7 @@ public function __construct() {
return;
}
$this->title = __( 'Sources Chart', 'disciple_tools' );
$this->base_title = __( 'Contacts', 'disciple_tools' );
$this->base_title = __( 'Access', 'disciple_tools' );

$url_path = dt_get_url_path( true );
if ( "metrics/$this->base_slug/$this->slug" === $url_path ) {
Expand Down
61 changes: 28 additions & 33 deletions dt-metrics/metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,78 +41,73 @@ public function __construct(){
new DT_Metrics_Groups_Genmap( 'personal', __( 'Personal', 'disciple_tools' ) );
require_once( get_template_directory() . '/dt-metrics/records/dynamic-records-map.php' );
new DT_Metrics_Dynamic_Records_Map( 'personal', __( 'Personal', 'disciple_tools' ) );
require_once( get_template_directory() . '/dt-metrics/personal/coaching-tree.php' );
require_once( get_template_directory() . '/dt-metrics/personal/baptism-tree.php' );
require_once( get_template_directory() . '/dt-metrics/personal/group-tree.php' );
// require_once( get_template_directory() . '/dt-metrics/personal/coaching-tree.php' );
// require_once( get_template_directory() . '/dt-metrics/personal/baptism-tree.php' );
// require_once( get_template_directory() . '/dt-metrics/personal/group-tree.php' );

require_once( get_template_directory() . '/dt-metrics/personal/mapbox-contacts-maps.php' );
require_once( get_template_directory() . '/dt-metrics/personal/mapbox-groups-maps.php' );
// require_once( get_template_directory() . '/dt-metrics/personal/mapbox-contacts-maps.php' );
// require_once( get_template_directory() . '/dt-metrics/personal/mapbox-groups-maps.php' );
require_once( get_template_directory() . '/dt-metrics/personal/activity-highlights.php' );
require_once( get_template_directory() . '/dt-metrics/personal/activity-log.php' );
require_once( get_template_directory() . '/dt-metrics/personal/overview.php' );

require_once( get_template_directory() . '/dt-metrics/combined/mapbox-maps.php' );
//...require_once( get_template_directory() . '/dt-metrics/combined/mapbox-maps.php' );

require_once( get_template_directory() . '/dt-metrics/records/records-endpoints.php' );

if ( dt_has_permissions( [ 'dt_all_access_contacts', 'view_project_metrics' ] ) ){ // tests if project level permissions
/* Contacts */
if ( !empty( $modules['dmm_module']['enabled'] ) ){
require_once( get_template_directory() . '/dt-metrics/contacts/baptism-tree.php' );
require_once( get_template_directory() . '/dt-metrics/contacts/coaching-tree.php' );
require_once( get_template_directory() . '/dt-metrics/contacts/milestones.php' );
require_once( get_template_directory() . '/dt-metrics/contacts/milestones-map.php' );
}
// if ( !empty( $modules['dmm_module']['enabled'] ) ){
//...require_once( get_template_directory() . '/dt-metrics/contacts/baptism-tree.php' );
//...require_once( get_template_directory() . '/dt-metrics/contacts/coaching-tree.php' );
// require_once( get_template_directory() . '/dt-metrics/contacts/milestones.php' );
// ...require_once( get_template_directory() . '/dt-metrics/contacts/milestones-map.php' );
// }
if ( !empty( $modules['access_module']['enabled'] ) ){
require_once( get_template_directory() . '/dt-metrics/contacts/mapbox-maps.php' );
//...require_once( get_template_directory() . '/dt-metrics/contacts/mapbox-maps.php' );
require_once( get_template_directory() . '/dt-metrics/contacts/sources.php' );
require_once( get_template_directory() . '/dt-metrics/contacts/overview.php' );
//...require_once( get_template_directory() . '/dt-metrics/contacts/overview.php' );
}

/* Groups */
require_once( get_template_directory() . '/dt-metrics/groups/tree.php' );
/*require_once( get_template_directory() . '/dt-metrics/groups/tree.php' );
require_once( get_template_directory() . '/dt-metrics/groups/mapbox-maps.php' );
require_once( get_template_directory() . '/dt-metrics/groups/overview.php' );
require_once( get_template_directory() . '/dt-metrics/groups/overview.php' );*/

// Combined
require_once( get_template_directory() . '/dt-metrics/combined/site-links.php' );
require_once( get_template_directory() . '/dt-metrics/combined/daily-activity.php' );
//..require_once( get_template_directory() . '/dt-metrics/combined/daily-activity.php' );
require_once( get_template_directory() . '/dt-metrics/combined/locations-list.php' );
require_once( get_template_directory() . '/dt-metrics/combined/hover-map.php' );

/* Record Types */
require_once( get_template_directory() . '/dt-metrics/records/date-range-activity.php' );
require_once( get_template_directory() . '/dt-metrics/records/time-charts.php' );
require_once( get_template_directory() . '/dt-metrics/records/select-tags-charts.php' );
new DT_Metrics_Groups_Genmap( 'records', __( 'Genmap', 'disciple_tools' ) );
new DT_Metrics_Dynamic_Records_Map( 'records', __( 'Records Map', 'disciple_tools' ) );
new DT_Metrics_Dynamic_Records_Map( 'records', __( 'Maps', 'disciple_tools' ) );
require_once( get_template_directory() . '/dt-metrics/combined/hover-map.php' );
}
if ( !empty( $modules['access_module']['enabled'] ) ){
require_once( get_template_directory() . '/dt-metrics/combined/critical-path.php' );
}
require_once( get_template_directory() . '/dt-metrics/records/select-tags-charts.php' );
require_once( get_template_directory() . '/dt-metrics/records/time-charts.php' );
require_once( get_template_directory() . '/dt-metrics/records/date-range-activity.php' );
}, 1000);

// default menu order
add_filter( 'dt_metrics_menu', function ( $content ){
$modules = dt_get_option( 'dt_post_type_modules' );
if ( $content === '' ){

$content .= '<li><a>' . __( 'Personal', 'disciple_tools' ) . '</a>
<ul class="menu vertical nested" id="personal-menu"></ul>
</li>';

if ( dt_has_permissions( [ 'dt_all_access_contacts', 'view_project_metrics' ] ) ){
//if ( !empty( $modules['dmm_module']['enabled'] ) ){
// $content .= '<li><a>' . __( 'Contacts', 'disciple_tools' ) . '</a>
// <ul class="menu vertical nested" id="contacts-menu"></ul>
// </li>';
//ß}
$content .= '<li><a>' . __( 'Project', 'disciple_tools' ) . '</a>
<ul class="menu vertical nested" id="combined-menu"></ul>
</li>';
if ( !empty( $modules['dmm_module']['enabled'] ) ){
$content .= '<li><a>' . __( 'Contacts', 'disciple_tools' ) . '</a>
<ul class="menu vertical nested" id="contacts-menu"></ul>
</li>';
}
$content .= '<li><a>' . __( 'Groups', 'disciple_tools' ) . '</a>
<ul class="menu vertical nested" id="groups-menu"></ul>
</li>';
$content .= '<li><a>' . __( 'Dynamic Metrics', 'disciple_tools' ) . '</a>
<ul class="menu vertical nested" id="records-menu"></ul>
</li>';
} // permission check
Expand Down
2 changes: 1 addition & 1 deletion dt-metrics/records/date-range-activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct() {
return;
}

$this->title = __( 'Field Activity', 'disciple_tools' );
$this->title = __( 'Activity Logs', 'disciple_tools' );
$this->base_title = __( 'Project', 'disciple_tools' );

$url_path = dt_get_url_path( true );
Expand Down
2 changes: 1 addition & 1 deletion dt-metrics/records/dynamic-records-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct( $base_slug, $base_title ) {

parent::__construct();

$this->title = __( 'Records Map', 'disciple_tools' );
$this->title = __( 'Maps', 'disciple_tools' );

// Build post types array, ignoring some for now.
// TODO: Only select post types with valid location field types!
Expand Down
4 changes: 2 additions & 2 deletions dt-metrics/records/genmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct( $base_slug, $base_title ) {

parent::__construct();

$this->title = __( 'Generational Trees', 'disciple_tools' );
$this->title = __( 'GenMapper Trees', 'disciple_tools' );

$url_path = dt_get_url_path( true );
if ( "metrics/$this->base_slug/$this->slug" === $url_path ) {
Expand Down Expand Up @@ -132,7 +132,7 @@ public function scripts() {
'map_key' => empty( DT_Mapbox_API::get_key() ) ? '' : DT_Mapbox_API::get_key(),
'data' => [],
'translations' => [
'title' => __( 'Generational Trees', 'disciple_tools' ),
'title' => $this->title,
'show_archived' => __( 'Show Archived', 'disciple_tools' ),
'data_layer_title' => __( 'Data Layers', 'disciple_tools' ),
'data_layer_settings_color_label' => __( 'Node Color', 'disciple_tools' ),
Expand Down
2 changes: 1 addition & 1 deletion dt-metrics/records/select-tags-charts.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct() {
return;
}

$this->title = __( 'Field Cumulative Values', 'disciple_tools' );
$this->title = __( 'Simple Chart', 'disciple_tools' );
$this->base_title = __( 'Project', 'disciple_tools' );

$url_path = dt_get_url_path( true );
Expand Down
2 changes: 1 addition & 1 deletion dt-metrics/records/time-charts.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct() {
return;
}

$this->title = __( 'Field Charts', 'disciple_tools' );
$this->title = __( 'Advanced Charts', 'disciple_tools' );
$this->base_title = __( 'Project', 'disciple_tools' );

$url_path = dt_get_url_path( true );
Expand Down

0 comments on commit 3f7318d

Please sign in to comment.