Skip to content

Commit e6dbff2

Browse files
committed
Use custom title and remove space between textarea and go button
1 parent 006e341 commit e6dbff2

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

classes/output/mobile.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class mobile {
3232
* @param array $args Data provided by standard CoreBlockDelegate.
3333
*/
3434
public static function get_block_content($args) {
35-
global $CFG, $OUTPUT;
35+
global $CFG, $DB, $OUTPUT;
3636

3737
$context = \core\context\block::instance($args['blockid']);
3838

@@ -60,6 +60,16 @@ public static function get_block_content($args) {
6060
$assistantname = get_config('block_openai_chat', 'assistantname') ? get_config('block_openai_chat', 'assistantname') : get_string('defaultassistantname', 'block_openai_chat');
6161
$username = get_config('block_openai_chat', 'username') ? get_config('block_openai_chat', 'username') : get_string('defaultusername', 'block_openai_chat');
6262

63+
$title = get_string('openai_chat', 'block_openai_chat');
64+
$configdata = $DB->get_field('block_instances', 'configdata', ['id' => $context->instanceid]);
65+
if (!empty($configdata)) {
66+
$cfg = base64_decode($configdata);
67+
$cfg = unserialize_object($cfg);
68+
if (!empty($cfg->title)) {
69+
$title = $cfg->title;
70+
}
71+
}
72+
6373
// Then, override with local settings if available
6474
if (!empty($config)) {
6575
$assistantname = (property_exists($config, 'assistantname') && $config->assistantname) ? $config->assistantname : $assistantname;
@@ -77,6 +87,7 @@ public static function get_block_content($args) {
7787
'assistantname' => $assistantname,
7888
'showlabelscss' => $showlabelscss,
7989
'contextid' => $context->id,
90+
'title' => $title,
8091
];
8192

8293
return [

db/mobile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
],
3636
'styles' => [
3737
'url' => $CFG->wwwroot . '/blocks/openai_chat/styles.css',
38-
'version' => 8,
38+
'version' => 11,
3939
],
4040
],
4141
],

styles.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
filter: brightness(0.8);
2929
}
3030

31-
.block_openai_chat #control_bar #go {
31+
.block_openai_chat #control_bar #go,
32+
#control_bar #go button.button-native {
3233
border-radius: 0 0.5rem 0.5rem 0;
3334
}
3435

@@ -318,3 +319,9 @@ ion-card.block_openai_chat .openai_message.bot {
318319
opacity: 1;
319320
}
320321
}
322+
323+
.block_openai_chat .card-title:before{
324+
content: url(https://ccaa-digital.s3.amazonaws.com/CSS%20style/stars.png);
325+
display: inline-block;
326+
margin-right: 0.25em;
327+
}

templates/mobile.mustache

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,29 @@
2929
}}
3030
{{=<% %>=}}
3131
<div style="padding: 0 0.5em 0.5em 0.5em">
32-
<h3><%#str%> openai_chat, block_openai_chat <%/str%></h3>
32+
<h3><% title %></h3>
3333
<div id="openai_chat_log" role="log"></div>
3434
<div id="control_bar">
3535
<div class="openai_input_bar" id="input_bar">
36-
<textarea aria-label="<%#str%>askaquestion, block_openai_chat<%/str%>" rows=1 id="openai_input" placeholder="<%#str%>askaquestion, block_openai_chat<%/str%>" type="text" name="message" core-auto-rows [(ngModel)]="CONTENT_OTHERDATA.message"></textarea>
36+
<textarea
37+
style="background-color: white; color: black;"
38+
aria-label="<%#str%>askaquestion, block_openai_chat<%/str%>"
39+
rows=1 id="openai_input" placeholder="<%#str%>askaquestion, block_openai_chat<%/str%>"
40+
type="text" name="message"
41+
core-auto-rows
42+
[(ngModel)]="CONTENT_OTHERDATA.message"></textarea>
43+
44+
<ion-button id="go" style="width: 1em; height: 1em; margin: 0;"
45+
core-site-plugins-call-ws
46+
name="block_openai_chat_answer"
47+
component="block_openai_chat" method="answer" samePage="true" showError="false"
48+
[params]="{contextid: <% contextid %>}"
49+
(onSuccess)="this.answer($event)"
50+
(onError)="this.answer($event)"
51+
[useOtherDataForWS]="['message']"
52+
><img style="transform: scale(1.3)" src="<%config.wwwroot%><% pix_arrow_right %>" alt="<%#str%>askaquestion, block_openai_chat<%/str%>" class='openai_input_submit_btn_icon'>
53+
</ion-button>
3754
</div>
38-
<ion-button id="chat-send" style="width: 1em; height: 1em; margin: 0;"
39-
core-site-plugins-call-ws
40-
name="block_openai_chat_answer"
41-
component="block_openai_chat" method="answer" samePage="true" showError="false"
42-
[params]="{contextid: <% contextid %>}"
43-
(onSuccess)="this.answer($event)"
44-
(onError)="this.answer($event)"
45-
[useOtherDataForWS]="['message']"
46-
><img style="transform: scale(1.3)" src="<%config.wwwroot%><% pix_arrow_right %>" alt="<%#str%>askaquestion, block_openai_chat<%/str%>" class='openai_input_submit_btn_icon'>
47-
</ion-button>
4855
<ion-button class='openai_input_refresh_btn' style="width: 1em; height: 1em; margin: 0;" color="secondary"
4956
title="<%#str%>new_chat, block_openai_chat <%/str%>" id="refresh">
5057
<img style="transform: scale(1.3)" src="<%config.wwwroot%><% pix_refresh %>" class='openai_input_refresh_btn_icon' alt="<%#str%>new_chat, block_openai_chat <%/str%>" />

0 commit comments

Comments
 (0)