Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: various improvements in styling and error handling #64

Merged
merged 5 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions frappe/custom/doctype/customize_form/customize_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ frappe.ui.form.on("Customize Form", {

onload: function (frm) {
frm.set_query("doc_type", function () {
let filters = [
["DocType", "custom", "=", 0],
["DocType", "name", "not in", frappe.model.core_doctypes_list],
["DocType", "restrict_to_domain", "in", frappe.boot.active_domains],
];
if (!frappe.boot.developer_mode) {
filters.push(["DocType", "issingle", "=", 0]);
}
return {
filters: [
["DocType", "issingle", "=", 0],
["DocType", "custom", "=", 0],
["DocType", "name", "not in", frappe.model.core_doctypes_list],
["DocType", "restrict_to_domain", "in", frappe.boot.active_domains],
],
filters: filters,
};
});

Expand Down
2 changes: 1 addition & 1 deletion frappe/custom/doctype/customize_form/customize_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def validate_doctype(self, meta):
if self.doc_type in core_doctypes_list:
frappe.throw(_("Core DocTypes cannot be customized."))

if meta.issingle:
if meta.issingle and not frappe.conf.get("developer_mode"):
frappe.throw(_("Single DocTypes cannot be customized."))

if meta.custom:
Expand Down
121 changes: 1 addition & 120 deletions frappe/public/scss/common/buttons.scss
Original file line number Diff line number Diff line change
@@ -1,126 +1,7 @@
.center-content {
display: flex;
justify-content: center;
align-items: center;
}

.btn {
border: none;
border-radius: var(--border-radius);
box-shadow: var(--btn-shadow);
font-size: var(--text-md);
&.icon-btn {
height: var(--btn-height);
padding: 0px;
@extend .center-content;
&.btn-default, &.btn-secondary {
min-width: 28px;
}
}
}

.btn-secondary-dark {
@include button-variant(
$background: $gray-600,
$border: $gray-600,
$hover-background: lighten($gray-600, 1%),
$hover-border: $gray-600,
$active-background: lighten($gray-600, 1%),
$active-border: darken($gray-600, 12.5%)
);

color: $white;
&:hover, &:active, &:focus {
color: $white;
}
.icon {
--icon-stroke: currentColor;
}
}

.btn-primary-light {
@include button-variant(
$background: $primary-light,
$border: $primary-light,
$hover-background: lighten($primary-light, 1%),
$hover-border: $primary-light,
$active-background: lighten($primary-light, 1%),
$active-border: darken($primary-light, 12.5%)
);

color: var(--primary);
&:hover, &:active {
color: var(--primary);
}

&:focus {
box-shadow: 0 0 0 0.2rem var(--primary-light);
}
}

.btn.btn-secondary {
background-color: var(--btn-secondary-bg);
color: var(--text-color);
&:hover {
background-color: var(--btn-secondary-hover-bg);
color: var(--text-color);
}
&:not(:disabled):not(.disabled):active {
background: var(--btn-secondary-active-bg);
color: var(--text-color);
}
}

.btn.btn-default {
background-color: var(--btn-default-bg);
color: var(--text-color);
&:hover {
background: var(--btn-default-hover-bg);
color: var(--text-color);
}
&:not(:disabled):not(.disabled):active {
background: var(--btn-default-active-bg);
color: var(--text-color);
}
}

.btn.btn-primary {
background-color: var(--btn-primary-bg);
color: var(--white);
white-space: nowrap;
--icon-stroke: currentColor;
--icon-fill-bg: var(--btn-primary-bg);

&:hover {
@if $btn-primary-hover-bg {
color: var(--white);
background-color: var(--btn-primary-hover-bg);
}
}
&:not(:disabled):not(.disabled):active {
@if $btn-primary-active-bg {
color: var(--white);
background-color: var(--btn-primary-active-bg);
}
}
}

//.btn.btn-danger {
// background-color: var(--red-400);
// color: $white;
//}

.btn-reset {
padding: 0;
margin: 0;
border: 0;
font-size: inherit;
background-color: inherit;
}

[data-theme="dark"] {
.btn-primary-light {
background-color: var(--bg-dark-blue);
box-shadow: none;
}
}
}
119 changes: 119 additions & 0 deletions frappe/public/scss/desk/buttons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
.center-content {
display: flex;
justify-content: center;
align-items: center;
}

.btn {
border: none;
border-radius: var(--border-radius);
box-shadow: var(--btn-shadow);
font-size: var(--text-md);
&.icon-btn {
height: var(--btn-height);
padding: 0px;
@extend .center-content;
&.btn-default, &.btn-secondary {
min-width: 28px;
}
}
}

.btn-secondary-dark {
@include button-variant(
$background: $gray-600,
$border: $gray-600,
$hover-background: lighten($gray-600, 1%),
$hover-border: $gray-600,
$active-background: lighten($gray-600, 1%),
$active-border: darken($gray-600, 12.5%)
);

color: $white;
&:hover, &:active, &:focus {
color: $white;
}
.icon {
--icon-stroke: currentColor;
}
}

.btn-primary-light {
@include button-variant(
$background: $primary-light,
$border: $primary-light,
$hover-background: lighten($primary-light, 1%),
$hover-border: $primary-light,
$active-background: lighten($primary-light, 1%),
$active-border: darken($primary-light, 12.5%)
);

color: var(--primary);
&:hover, &:active {
color: var(--primary);
}

&:focus {
box-shadow: 0 0 0 0.2rem var(--primary-light);
}
}

.btn.btn-secondary {
background-color: var(--btn-secondary-bg);
color: var(--text-color);
&:hover {
background-color: var(--btn-secondary-hover-bg);
color: var(--text-color);
}
&:not(:disabled):not(.disabled):active {
background: var(--btn-secondary-active-bg);
color: var(--text-color);
}
}

.btn.btn-default {
background-color: var(--btn-default-bg);
color: var(--text-color);
&:hover {
background: var(--btn-default-hover-bg);
color: var(--text-color);
}
&:not(:disabled):not(.disabled):active {
background: var(--btn-default-active-bg);
color: var(--text-color);
}
}

.btn.btn-primary {
background-color: var(--btn-primary-bg);
color: var(--white);
white-space: nowrap;
--icon-stroke: currentColor;
--icon-fill-bg: var(--btn-primary-bg);

&:hover {
@if $btn-primary-hover-bg {
color: var(--white);
background-color: var(--btn-primary-hover-bg);
}
}
&:not(:disabled):not(.disabled):active {
@if $btn-primary-active-bg {
color: var(--white);
background-color: var(--btn-primary-active-bg);
}
}
}

.btn.btn-danger {
background-color: var(--red-400);
color: $white;
}


[data-theme="dark"] {
.btn-primary-light {
background-color: var(--bg-dark-blue);
box-shadow: none;
}
}
3 changes: 2 additions & 1 deletion frappe/public/scss/desk/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
@import "../common/mixins.scss";
@import "../common/global.scss";
@import "../common/icons.scss";
@import "../common/alert.scss";
@import "alert";

@import "~bootstrap/scss/bootstrap";
@import "global";
@import "../common/buttons";
@import "buttons";
@import "../common/flex";
@import "mobile";
@import "module.scss";
Expand Down
1 change: 0 additions & 1 deletion frappe/public/scss/website/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@import "../common/mixins";
@import "../common/global";
@import "../common/icons";
@import "../common/alert";
@import "../common/flex";
@import "../common/buttons";
@import "../common/modal";
Expand Down
4 changes: 2 additions & 2 deletions frappe/templates/includes/comments/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<textarea class="form-control" name="comment" rows=5 ></textarea>
<div class="text-muted small mt-1 mb-4">{{ _("Ctrl+Enter to add comment") }}</div>
</div>
<button class="btn btn-sm small" id="submit-comment">{{ _("Comment") }}</button>
<button class="btn btn-default btn-sm small" id="submit-comment">{{ _("Comment") }}</button>
</fieldset>
</form>
</div>
Expand All @@ -44,7 +44,7 @@
<div itemscope itemtype="http://schema.org/UserComments" id="comment-list">
<div class="add-comment mb-5">
<div class="timeline-dot"></div>
<button class="btn btn-sm small add-comment-button">{{ _("Add a comment") }}</button>
<button class="btn btn-default btn-sm small add-comment-button">{{ _("Add a comment") }}</button>
</div>
<div class="comment-list">
{% for comment in comment_list %}
Expand Down
3 changes: 3 additions & 0 deletions frappe/website/js/website.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ $.extend(frappe, {
}
}
frappe.process_response(opts, data);
}).fail(function (xhr) {
opts.error && opts.error(xhr);
});
},
prepare_call: function (opts) {
Expand Down Expand Up @@ -212,6 +214,7 @@ $.extend(frappe, {
btn: btn,
args: opts.args,
callback: opts.callback,
error: opts.error,
});
},
has_permission: function (doctype, docname, perm_type, callback) {
Expand Down
3 changes: 3 additions & 0 deletions frappe/www/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def get_context(context):
@frappe.whitelist(allow_guest=True)
@rate_limit(limit=1000, seconds=60 * 60)
def send_message(sender, message, subject="Website Query", args=None, create_communication=1):
if not sender:
frappe.throw(_("Please enter your email address"))

sender = validate_email_address(sender, throw=True)

if not args:
Expand Down
Loading