I am trying to write my first plugin for Bitbucket. I followed the tutorial to add a custom column to the branches list. It works great. After, I wanted to add a custom column to the repositories list with e.g. description or number of branches. However, when I check for web sections with:
http://localhost:7990/bitbucket/projects/PROJECT_1?web.sections
I do not see any on the repositories list page. Is it possible to add there some column?
Adam
it isn't supported by the Atlassian's layout
The project overview template contains a code
{if not $isEmptyProject}
{call bitbucket.internal.feature.repository.repositoryTable}
{param id: 'repositories-table' /}
{param repositoryPage: $repositoryPage /}
{param showPublicStatus: true /}
{/call}
{/if}
and the table row definition in the bitbucket.internal.feature.repository.repositoryTable template is
{template .repositoryRow private="true"}
<tr>
<td>
{if $showProject}
<span class="project-name">
{call bitbucket.internal.feature.project.avatar}
{param size: 'small' /}
{param project: $repository.project /}
{/call}
{$repository.project.name}
</span>
{/if}
<span class="repository-name">
{if not $showProject}
{call aui.icons.icon}
{param size: 'small' /}
{param useIconFont: true /}
{param iconFontSet: 'devtools' /}
{param icon: $repository.origin ? 'repository-forked' : 'repository' /}
{param accessibilityText: $repository.origin ? getText('bitbucket.web.repository.repository.forked') : getText('bitbucket.web.repository.repository')/}
{{param extraAttributes: $repository.origin ? ['title': getText('bitbucket.web.repository.is.a.fork.of', $repository.origin.project.name, $repository.origin.name)] : null/}}
{/call}
{/if}
{$repository.name}
</span>
{if $showPublicStatus}
{call bitbucket.internal.feature.repository.publicLozenge}
{param repository: $repository /}
{/call}
{/if}
</td>
</tr>
The only way is to replace somehow the .repositoryRow template, but I don't see a proper way to do it without hacking
Related
Hello i need some help with a basic question. This is my code:
{foreach $sArticle.attributes.core->toArray() as $attribute}
<tr class="product--properties-row">
<td class="product--properties-label is--bold">{$sArticle.attributes.name}{$sArticle.attributesName}</td>
<td class="product--properties-label is--bold">{$attribute}</td>
</tr>
{/foreach}
1.Question: How do I enter the attributes name? I mean the column name from the attribute in the database?
2.Question: I only want to loop with the foreach through columns with name="artikelattr_" any idea how this can be done?
Thanks
I adjusted my answer here: https://stackoverflow.com/a/71237355/7201069
How to get the name of the attribute.
To consider only certain attributes that starts with a specific string, just add an if in the loop:
{foreach $sArticle.attributes.core->toArray() as $attributeName => $attribute}
{if $attributeName|strpos:"artikelattr_" === 0}
{$attributeName|var_dump}
{$attribute|var_dump}
{/if}
{/foreach}
You can simply use nearly all PHP functions in Smarty.
I have a list in Thymeleaf and I want to use th:with in a div to grab the last element in a list. I've tried:
<div th:if="${not #lists.isEmpty(licence.registrations)}"
th:with="lastRegistation=${licence.registrations[__(#lists.size(licence.registrations) - 1)__]}">
<tr>
<td>Name</td>
<td><span th:text="${lastRegistration.name}"/></td>
</tr>
</div>
However this gives me the error:
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "(#lists.size(licence.registrations) - 1)" (template: "admin/viewLicence.html" - line 103, col 10)
Does anyone know a way I can get the last item in a list with Thymeleaf?
Cheers,
Neil
If you're using preprocessing, you need to surround the expression with ${...}. Like this:
th:with="lastRegistration=${licence.registrations[__${#lists.size(licence.registrations) - 1}__]}"
That being said, there is no reason to use preprocessing in this case. (And I would remove the extra unused tags as well.) This will work:
<tr th:if="${not #lists.isEmpty(licence.registrations)}"
th:with="lastRegistration=${licence.registrations[#lists.size(licence.registrations) - 1]}">
<td>Name</td>
<td th:text="${lastRegistration.name}" />
</tr>
You can also get fancy with collection selection & projection, but I'm not sure this is an appropriate use. Still, it seems to work:
<tr th:if="${not #lists.isEmpty(licence.registrations)}">
<td>Name</td>
<td th:text="${licence.registrations.![name].$[true]}" />
</tr>
I need, for specific category, on single product page and category page and every other page, a custom badge. So if product is on category ID 14 display badge name "Premium" (of product is new or in sale must be appears also this badge unit "Premium").
I try to do this but not work (I put on products-list.tpl).
{assign var='premium' value=0}
{foreach Product::getProductCategories($smarty.get.id_product) as $category}
{if in_array($category, 14)}
{assign var='premium' value=1}
{/if}
{/foreach}
{if $associated==1}
<div class =" origine-GB "> </ div>
{/if}
Not work :(
First I must say this is quick hack and that proper way would be to make a module with custom hook maybe. But here is code you are aiming got.
In product-list.tpl add
{assign var='premium' value=0}
{if in_array('14', Product::getProductCategories($product.id_product))}
{assign var='premium' value=1}
{/if}
{if $premium==1}
<div class =" origine-GB "> </ div>
{/if}
And forproduct.tpl use
{assign var='premium' value=0}
{if in_array('14', Product::getProductCategories($product->id))}
{assign var='premium' value=1}
{/if}
{if $premium==1}
<div class =" origine-GB"> </ div>
{/if}
You were setting premium variable but use associated later.
Also in_array goes other way around in_array.
In an ng-repeat I want to add a hide-xs attribute on an element based on the current scope.
How can I do that?
I basically want to do something like (this obviously don't work):
<li ng-repeat="item in items" hide-xs="{{ item.showAlways ? 'false' : 'true' }}">
{{item.title}}
</li>
Edit
I ended up doing this (as suggested by DieuNQ) but if anybody know how to do it using directive and not class I would take it
<li ng-repeat="item in items" ng-class="{'hide-xs': !item.showAlways }}">
{{item.title}}
</li>
hide-xs not works like that (it does not depend on true or false). It just add class to your tag. Try this:
In your html:
<li ng-repeat="item in items" ng-model="item.showAlways" ng-class="someClass">
...
</li>
In your controller:
$scope.item.showAlways ? $scope.someClass == '' : $scope.someClass == 'hide-xs';
This code find my first letter and show it. But how can remove it?
Like: From EDCstreet to street.
{foreach from=$elements item=street}
{if $street|substr:0:1 eq 'm'}
{$street}
{/if}
{/foreach}
You can use:
{foreach from=$elements item=street}
{if $street|substr:0:1 eq 'm'}
{$street|substr:1}
{/if}
{/foreach}
to display text without this first letter