| 1 |
<?php |
| 2 |
/** |
| 3 |
* Single project template: bugs |
| 4 |
* |
| 5 |
* @package UpStream |
| 6 |
*/ |
| 7 |
|
| 8 |
// Prevent direct access. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
if ( ! upstream_are_bugs_disabled() && ! upstream_disable_bugs() ) : |
| 14 |
|
| 15 |
$collapse_box = isset( $plugin_options['collapse_project_bugs'] ) |
| 16 |
&& true === (bool) $plugin_options['collapse_project_bugs']; |
| 17 |
|
| 18 |
$collapse_box_state = \UpStream\Frontend\upstream_get_section_collapse_state( 'bugs' ); |
| 19 |
|
| 20 |
if ( false !== $collapse_box_state ) { |
| 21 |
$collapse_box = 'closed' === $collapse_box_state; |
| 22 |
} |
| 23 |
|
| 24 |
$archive_closed_items = upstream_archive_closed_items(); |
| 25 |
$bugs_settings = get_option( 'upstream_bugs' ); |
| 26 |
$bugs_statuses = $bugs_settings['statuses']; |
| 27 |
$statuses = array(); |
| 28 |
$open_statuses = array(); |
| 29 |
|
| 30 |
foreach ( $bugs_statuses as $up_status ) { |
| 31 |
// If closed items will be archived, we do not need to display closed statuses. |
| 32 |
if ( $archive_closed_items && 'open' !== $up_status['type'] ) { |
| 33 |
continue; |
| 34 |
} |
| 35 |
|
| 36 |
$statuses[ $up_status['id'] ] = $up_status; |
| 37 |
|
| 38 |
if ( 'open' === $up_status['type'] ) { |
| 39 |
$open_statuses[] = $up_status['id']; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
$bugs_severities = $bugs_settings['severities']; |
| 44 |
$severities = array(); |
| 45 |
|
| 46 |
foreach ( $bugs_severities as $index => $severity ) { |
| 47 |
$severity['order'] = $index; |
| 48 |
|
| 49 |
$severities[ $severity['id'] ] = $severity; |
| 50 |
} |
| 51 |
|
| 52 |
unset( $bugs_severities ); |
| 53 |
|
| 54 |
$item_type = 'bug'; |
| 55 |
$current_user_id = get_current_user_id(); |
| 56 |
$users = upstream_admin_get_all_project_users(); |
| 57 |
$project_id = upstream_post_id(); |
| 58 |
$rowset = UpStream_View::get_bugs( $project_id ); |
| 59 |
|
| 60 |
// If should archive closed items, we filter the rowset. |
| 61 |
if ( $archive_closed_items ) { |
| 62 |
foreach ( $rowset as $up_id => $bug ) { |
| 63 |
if ( ! in_array( $bug['status'], $open_statuses ) && ! empty( $bug['status'] ) ) { |
| 64 |
unset( $rowset[ $up_id ] ); |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
$l = array( |
| 70 |
'LB_TITLE' => __( 'Title', 'upstream' ), |
| 71 |
'LB_NONE' => __( 'none', 'upstream' ), |
| 72 |
'LB_DESCRIPTION' => __( 'Description', 'upstream' ), |
| 73 |
'LB_COMMENTS' => __( 'Comments', 'upstream' ), |
| 74 |
'MSG_INVALID_USER' => sprintf( |
| 75 |
// translators: %s: column name. Error message when data reference is not found. |
| 76 |
_x( 'invalid %s', '%s: column name. Error message when data reference is not found', 'upstream' ), |
| 77 |
strtolower( __( 'User' ) ) |
| 78 |
), |
| 79 |
'LB_DUE_DATE' => __( 'Due Date', 'upstream' ), |
| 80 |
); |
| 81 |
|
| 82 |
$are_comments_enabled = upstream_are_comments_enabled_on_bugs(); |
| 83 |
|
| 84 |
$table_settings = array( |
| 85 |
'id' => 'bugs', |
| 86 |
'type' => 'bug', |
| 87 |
'data-ordered-by' => 'due_date', |
| 88 |
'data-order-dir' => 'DESC', |
| 89 |
); |
| 90 |
|
| 91 |
$columns_schema = \UpStream\Frontend\upstream_get_bugs_fields( $severities, $statuses, $are_comments_enabled ); |
| 92 |
|
| 93 |
$filter_closed_items = upstream_filter_closed_items(); |
| 94 |
|
| 95 |
?> |
| 96 |
<div class="col-md-12 col-sm-12 col-xs-12"> |
| 97 |
<div class="x_panel" data-section="bugs"> |
| 98 |
<div class="x_title"> |
| 99 |
<h2> |
| 100 |
<i class="fa fa-bars sortable_handler"></i> |
| 101 |
<i class="fa fa-bug"></i> <?php echo esc_html( upstream_bug_label_plural() ); ?> |
| 102 |
</h2> |
| 103 |
<ul class="nav navbar-right panel_toolbox"> |
| 104 |
<li> |
| 105 |
<a class="collapse-link"> |
| 106 |
<i class="fa fa-chevron-<?php echo $collapse_box ? 'down' : 'up'; ?>"></i> |
| 107 |
</a> |
| 108 |
</li> |
| 109 |
<?php do_action( 'upstream_project_bugs_top_right', $project_id ); ?> |
| 110 |
</ul> |
| 111 |
<div class="clearfix"></div> |
| 112 |
</div> |
| 113 |
<div class="x_content" style="display: <?php echo $collapse_box ? 'none' : 'block'; ?>;"> |
| 114 |
<div class="c-data-table table-responsive"> |
| 115 |
<form class="form-inline c-data-table__filters" data-target="#bugs"> |
| 116 |
<div class="d-none d-sm-flex justify-content-between"> |
| 117 |
<div class="form-group"> |
| 118 |
<div class="input-group"> |
| 119 |
<div class="input-group-text"> |
| 120 |
<i class="fa fa-search"></i> |
| 121 |
</div> |
| 122 |
<input type="search" class="form-control" |
| 123 |
placeholder="<?php echo esc_attr( $l['LB_TITLE'] ); ?>" data-column="title" |
| 124 |
data-compare-operator="contains"> |
| 125 |
</div> |
| 126 |
</div> |
| 127 |
<div class="form-group"> |
| 128 |
<div class="btn-group"> |
| 129 |
<a href="#bugs-filters" role="button" class="btn border btn-light btn-sm" |
| 130 |
data-bs-toggle="collapse" aria-expanded="false" aria-controls="bugs-filters"> |
| 131 |
<i class="fa fa-filter"></i> <?php esc_html_e( 'Toggle Filters', 'upstream' ); ?> |
| 132 |
</a> |
| 133 |
</div> |
| 134 |
<div class="btn-group"> |
| 135 |
<button class="btn btn-light border btn-sm dropdown-toggle upstream-export-button" |
| 136 |
type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"> |
| 137 |
<i class="fa fa-download"></i> <?php esc_html_e( 'Export', 'upstream' ); ?> |
| 138 |
</button> |
| 139 |
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1"> |
| 140 |
<li><a class="dropdown-item" href="#" data-action="export" data-type="txt"> |
| 141 |
<i class="fa fa-file-text-o"></i> <?php esc_html_e( 'Plain Text', 'upstream' ); ?> |
| 142 |
</a></li> |
| 143 |
<li><a class="dropdown-item" href="#" data-action="export" data-type="csv"> |
| 144 |
<i class="fa fa-file-code-o"></i> <?php esc_html_e( 'CSV', 'upstream' ); ?> |
| 145 |
</a></li> |
| 146 |
</ul> |
| 147 |
</div> |
| 148 |
</div> |
| 149 |
</div> |
| 150 |
<div class="d-flex justify-content-between d-sm-none"> |
| 151 |
<div class="btn-group"> |
| 152 |
<a href="#bugs-filters" role="button" class="btn border btn-light btn-sm" |
| 153 |
data-bs-toggle="collapse" aria-expanded="false" aria-controls="bugs-filters"> |
| 154 |
<i class="fa fa-filter"></i> <?php esc_html_e( 'Toggle Filters', 'upstream' ); ?> |
| 155 |
</a> |
| 156 |
</div> |
| 157 |
<div class="btn-group"> |
| 158 |
<button class="btn btn-light border btn-sm dropdown-toggle upstream-export-button" |
| 159 |
type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"> |
| 160 |
<i class="fa fa-download"></i> <?php esc_html_e( 'Export', 'upstream' ); ?> |
| 161 |
</button> |
| 162 |
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1"> |
| 163 |
<li><a class="dropdown-item" href="#" data-action="export" data-type="txt"> |
| 164 |
<i class="fa fa-file-text-o"></i> <?php esc_html_e( 'Plain Text', 'upstream' ); ?> |
| 165 |
</a></li> |
| 166 |
<li><a class="dropdown-item" href="#" data-action="export" data-type="csv"> |
| 167 |
<i class="fa fa-file-code-o"></i> <?php esc_html_e( 'CSV', 'upstream' ); ?> |
| 168 |
</a></li> |
| 169 |
</ul> |
| 170 |
</div> |
| 171 |
</div> |
| 172 |
<div id="bugs-filters" class="collapse"> |
| 173 |
<div class="form-group d-block d-sm-none"> |
| 174 |
<div class="input-group"> |
| 175 |
<div class="input-group-text"> |
| 176 |
<i class="fa fa-search"></i> |
| 177 |
</div> |
| 178 |
<input type="search" class="form-control" |
| 179 |
placeholder="<?php echo esc_attr( $l['LB_TITLE'] ); ?>" data-column="title" |
| 180 |
data-compare-operator="contains"> |
| 181 |
</div> |
| 182 |
</div> |
| 183 |
<div class="form-group d-sm-inline-block"> |
| 184 |
<div class="input-group flex-nowrap"> |
| 185 |
<div class="input-group-text"> |
| 186 |
<i class="fa fa-user"></i> |
| 187 |
</div> |
| 188 |
<select class="form-control o-select2" data-column="assigned_to" |
| 189 |
data-placeholder="<?php esc_attr_e( 'Assignee', 'upstream' ); ?>" multiple> |
| 190 |
<option value></option> |
| 191 |
<option value="__none__"><?php esc_html_e( 'Nobody', 'upstream' ); ?></option> |
| 192 |
<option value="<?php echo esc_attr( $current_user_id ); ?>"> |
| 193 |
<?php |
| 194 |
esc_html_e( |
| 195 |
'Me', |
| 196 |
'upstream' |
| 197 |
); |
| 198 |
?> |
| 199 |
</option> |
| 200 |
<optgroup label="<?php esc_attr_e( 'Users' ); ?>"> |
| 201 |
<?php foreach ( $users as $user_id => $user_name ) : ?> |
| 202 |
<?php |
| 203 |
if ( $user_id === $current_user_id ) { |
| 204 |
continue; |
| 205 |
} |
| 206 |
?> |
| 207 |
<option value="<?php echo esc_attr( $user_id ); ?>"><?php echo esc_html( $user_name ); ?></option> |
| 208 |
<?php endforeach; ?> |
| 209 |
</optgroup> |
| 210 |
</select> |
| 211 |
</div> |
| 212 |
</div> |
| 213 |
<div class="form-group d-sm-inline-block"> |
| 214 |
<div class="input-group flex-nowrap"> |
| 215 |
<div class="input-group-text"> |
| 216 |
<i class="fa fa-asterisk"></i> |
| 217 |
</div> |
| 218 |
<select class="form-control o-select2" data-column="severity" |
| 219 |
data-placeholder="<?php esc_attr_e( 'Severity', 'upstream' ); ?>" multiple> |
| 220 |
<option value></option> |
| 221 |
<option value="__none__"><?php esc_html_e( 'None', 'upstream' ); ?></option> |
| 222 |
<optgroup label="<?php esc_attr_e( 'Severity', 'upstream' ); ?>"> |
| 223 |
<?php foreach ( $severities as $severity ) : ?> |
| 224 |
<option |
| 225 |
value="<?php echo esc_attr( $severity['id'] ); ?>"><?php echo esc_html( $severity['name'] ); ?></option> |
| 226 |
<?php endforeach; ?> |
| 227 |
</optgroup> |
| 228 |
</select> |
| 229 |
</div> |
| 230 |
</div> |
| 231 |
<div class="form-group d-sm-inline-block"> |
| 232 |
<div class="input-group flex-nowrap"> |
| 233 |
<div class="input-group-text"> |
| 234 |
<i class="fa fa-bookmark"></i> |
| 235 |
</div> |
| 236 |
<select class="form-control o-select2" data-column="status" |
| 237 |
data-placeholder="<?php esc_attr_e( 'Status', 'upstream' ); ?>" multiple> |
| 238 |
<option value></option> |
| 239 |
<option value="__none__" <?php echo $filter_closed_items ? 'selected' : ''; ?>> |
| 240 |
<?php |
| 241 |
esc_html_e( |
| 242 |
'None', |
| 243 |
'upstream' |
| 244 |
); |
| 245 |
?> |
| 246 |
</option> |
| 247 |
<optgroup label="<?php esc_html_e( 'Status', 'upstream' ); ?>"> |
| 248 |
<?php foreach ( $statuses as $up_status ) : ?> |
| 249 |
<?php |
| 250 |
$attr = ' '; |
| 251 |
if ( $filter_closed_items && 'open' === $up_status['type'] ) : |
| 252 |
$attr .= ' selected'; |
| 253 |
endif; |
| 254 |
?> |
| 255 |
<option value="<?php echo esc_attr( $up_status['id'] ); ?>"<?php echo esc_attr( $attr ); ?>><?php echo esc_html( $up_status['name'] ); ?></option> |
| 256 |
<?php endforeach; ?> |
| 257 |
</optgroup> |
| 258 |
</select> |
| 259 |
</div> |
| 260 |
</div> |
| 261 |
<div class="form-group d-sm-inline-block"> |
| 262 |
<div class="input-group"> |
| 263 |
<div class="input-group-text"> |
| 264 |
<i class="fa fa-calendar"></i> |
| 265 |
</div> |
| 266 |
<input type="text" class="form-control o-datepicker" |
| 267 |
placeholder="<?php echo esc_attr( $l['LB_DUE_DATE'] ); ?>" |
| 268 |
id="tasks-filter-due_date_from"> |
| 269 |
</div> |
| 270 |
<input type="hidden" id="tasks-filter-due_date_from_timestamp" data-column="due_date" |
| 271 |
data-compare-operator=">="> |
| 272 |
</div> |
| 273 |
|
| 274 |
<?php |
| 275 |
do_action( |
| 276 |
'upstream:project.bugs.filters', |
| 277 |
$table_settings, |
| 278 |
$columns_schema, |
| 279 |
$project_id |
| 280 |
); |
| 281 |
?> |
| 282 |
</div> |
| 283 |
</form> |
| 284 |
<?php |
| 285 |
\UpStream\Frontend\upstream_render_table( |
| 286 |
$table_settings, |
| 287 |
$columns_schema, |
| 288 |
$rowset, |
| 289 |
'bug', |
| 290 |
$project_id |
| 291 |
); |
| 292 |
?> |
| 293 |
</div> |
| 294 |
</div> |
| 295 |
</div> |
| 296 |
</div> |
| 297 |
<?php endif; ?> |
| 298 |
|