Skip to content

Commit

Permalink
feat(question,section): show conditions count
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Sep 7, 2020
1 parent 9a9a07f commit f462526
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,19 @@ span.fc_list_icon {
background: #fec95c;
}

/* Count of conditions in design view */
.plugin_formcreator_conditions_count {
border-radius: 50%;
background-color: #FFF;
min-width: 18px;
margin-right: 5px;
display: inline-block;
text-align: center;
vertical-align: top;
padding: 3px 2px 5px;
box-sizing: border-box;
}

/* ################--------------- Responsive ---------------#################### */
@media screen and (max-width: 700px) {
form#plugin_formcreator_form {
Expand Down
6 changes: 6 additions & 0 deletions inc/question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ public function getDesignHtml() {
$html .= $field->getHtmlIcon() . '&nbsp;';
$onclick = 'plugin_formcreator.showQuestionForm(' . $sectionId . ', ' . $questionId . ');';
$html .= '<a href="javascript:' . $onclick . '" data-field="name">';
// Show count of conditions
$nb = (new DBUtils())->countElementsInTable(PluginFormcreatorCondition::getTable(), [
'itemtype' => PluginFormcreatorSection::getType(),
'items_id' => $this->getID(),
]);
$html .= "<sup class='plugin_formcreator_conditions_count'>$nb</sup>";
$html .= empty($this->fields['name']) ? '(' . $questionId . ')' : $this->fields['name'];
$html .= '</a>';

Expand Down
6 changes: 6 additions & 0 deletions inc/section.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,12 @@ public function getDesignHtml() {

// section name
$html .= '<a href="#" ' . $onclick . ' data-field="name">';
// Show count of conditions
$nb = (new DBUtils())->countElementsInTable(PluginFormcreatorCondition::getTable(), [
'itemtype' => PluginFormcreatorSection::getType(),
'items_id' => $this->getID(),
]);
$html .= "<sup class='plugin_formcreator_conditions_count'>$nb</sup>";
$html .= empty($this->fields['name']) ? '(' . $sectionId . ')' : $this->fields['name'];
$html .= '</a>';

Expand Down

0 comments on commit f462526

Please sign in to comment.