File tree Expand file tree Collapse file tree 4 files changed +20
-6
lines changed
assets/javascripts/admin/addon
components/admin-config-areas Expand file tree Collapse file tree 4 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -35,17 +35,20 @@ export default class AdminConfigAreasColorPalettes extends Component {
35
35
@action
36
36
async newColorPaletteWithBase (baseKey ) {
37
37
let base;
38
+ let base_scheme_id;
38
39
if (baseKey && / ^ \d + $ / .test (baseKey)) {
39
40
base = this .allColorPalettes .findBy (" id" , baseKey);
41
+ base_scheme_id = - 1 ;
40
42
} else {
41
43
base = this .allColorPalettes .find (
42
44
(palette ) => palette .base_scheme_id === baseKey
43
45
);
46
+ base_scheme_id = base .get (" base_scheme_id" );
44
47
}
45
48
const newPalette = base .copy ();
46
49
newPalette .setProperties ({
47
50
name: i18n (" admin.customize.colors.new_name" ),
48
- base_scheme_id: base . get ( " base_scheme_id " ) ,
51
+ base_scheme_id,
49
52
});
50
53
await newPalette .save ();
51
54
await this .router .refresh ();
Original file line number Diff line number Diff line change @@ -178,16 +178,23 @@ export default class AdminCustomizeColorsController extends Controller {
178
178
@action
179
179
newColorSchemeWithBase ( baseKey ) {
180
180
let base ;
181
+ let base_scheme_id ;
181
182
if ( baseKey && / ^ \d + $ / . test ( baseKey ) ) {
182
183
base = this . model . content . findBy ( "id" , baseKey ) ;
184
+ base_scheme_id = - 1 ;
183
185
} else {
184
186
base = this . allBaseColorSchemes . findBy ( "base_scheme_id" , baseKey ) ;
187
+ base_scheme_id = base . get ( "base_scheme_id" ) ;
185
188
}
186
189
187
190
const newColorScheme = base . copy ( ) ;
188
191
newColorScheme . setProperties ( {
189
192
name : i18n ( "admin.customize.colors.new_name" ) ,
190
- base_scheme_id : base . get ( "base_scheme_id" ) ,
193
+ base_scheme_id,
194
+ } ) ;
195
+ newColorScheme . colors = newColorScheme . colors . map ( ( color ) => {
196
+ color . default_hex = null ;
197
+ return color ;
191
198
} ) ;
192
199
newColorScheme . save ( ) . then ( ( ) => {
193
200
this . model . pushObject ( newColorScheme ) ;
Original file line number Diff line number Diff line change @@ -56,6 +56,9 @@ export default class ColorSchemeColor extends EmberObject {
56
56
// Whether the saved value is different than Discourse's default color scheme.
57
57
@discourseComputed ( "default_hex" , "hex" )
58
58
savedIsOverriden ( defaultHex ) {
59
+ if ( ! defaultHex ) {
60
+ return false ;
61
+ }
59
62
return this . originals . hex !== defaultHex ;
60
63
}
61
64
Original file line number Diff line number Diff line change @@ -12,11 +12,12 @@ def dark_hex
12
12
end
13
13
14
14
def default_hex
15
- if object . color_scheme
16
- object . color_scheme . base_colors [ object . name ]
17
- else
18
- # it is a base color so it is already default
15
+ # return the hex value of the color when based on custom scheme
16
+ # or it is already a base color
17
+ if !object . color_scheme || object . color_scheme . base_scheme_id == "-1"
19
18
object . hex
19
+ else
20
+ object . color_scheme . base_colors [ object . name ]
20
21
end
21
22
end
22
23
You can’t perform that action at this time.
0 commit comments