Jump to content
  • Status: Moved to Github

I added a UINode extension on the \IPS\nexus\Package class but the rowBadge() method is not being executed at all. This happens because the code in the file returns NULL rather than calling the parent Model method that contains the ui() call:

	protected function get__badge(): ?array
	{
		if ( $this->deleteOrMoveQueued() === TRUE )
		{
			return array(
				0	=> 'ipsBadge ipsBadge--intermediary',
				1	=> 'mass_change_purchases_in_progress',
			);
		}

		if( $this->locked )
		{
			return array(
				0	=> 'ipsBadge ipsBadge--negative',
				1 	=> 'product_locked'
			);
		}

		return NULL;
	}

The parent Model method correctly calls the extension function at the end instead of returning NULL:

	protected function get__badge(): ?array
	{
		if ( $this->deleteOrMoveQueued() === TRUE )
		{
			return array(
				0	=> 'ipsBadge ipsBadge--intermediary',
				1	=> 'node_move_delete_queued',
			);
		}

		/* Check extensions for a possible badge */
		return $this->ui( 'rowBadge', array(), true );
	}

I tried replacing the NULL return locally with the ui() method and the badge was properly displayed.

User Feedback

Recommended Comments

teraßyte

Clients
(edited)

Another related issue to this location is that the code should not return the whole ipsBadge ipsBadge--intermediary CSS, but only intermediary because the code already automatically adds the ipsBadge ipsBadge-- part:

	protected function get__badge(): ?array
	{
		if ( $this->deleteOrMoveQueued() === TRUE )
		{
			return array(
				0	=> 'intermediary',
				1	=> 'mass_change_purchases_in_progress',
			);
		}

		if( $this->locked )
		{
			return array(
				0	=> 'negative',
				1 	=> 'product_locked'
			);
		}
		
		/* Check extensions for a possible badge */
		return $this->ui( 'rowBadge', array(), true );
	}

With the current code, the output is the following with a non-existent ipsBadge--ipsBadge CSS class:

<span class="ipsBadge ipsBadge--ipsBadge ipsBadge--negative">Locked</span>

After my change above the output is as expected:

<span class="ipsBadge ipsBadge--negative">Locked</span>

EDIT

This issue is present in a lot of other get__badge() functions from other classes, not just this one.

Edited by teraßyte