scroll into view the next step

This commit is contained in:
crunk 2022-03-04 21:10:06 +01:00
parent fc4b1a5c75
commit 0cb57548fa
9 changed files with 49 additions and 10 deletions

View File

@ -1,12 +1,9 @@
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import SubmitField, SelectField from wtforms import SubmitField, SelectField
from distribusimodel import Distribusis
from usermodel import User
from flask_login import current_user
class SelectorForm(FlaskForm): class SelectorForm(FlaskForm):
distribusis = SelectField(u'Your existing distribusi:') distribusis = SelectField("Your existing distribusi:")
new = SubmitField("new") new = SubmitField("new")

View File

@ -43,6 +43,7 @@ from upload import UploadUpdatedFiles
# UserPengguna # UserPengguna
from statuspengguna.helper import IsZipUploaded from statuspengguna.helper import IsZipUploaded
from statuspengguna.helper import IsCssSelected
from statuspengguna.helper import CurrentDistribusi from statuspengguna.helper import CurrentDistribusi
from statuspengguna.helper import ResetUserState from statuspengguna.helper import ResetUserState
from statuspengguna.loginuser import LoginUser from statuspengguna.loginuser import LoginUser
@ -86,6 +87,7 @@ def distribusi():
selectorvisible = SelectorVisible() selectorvisible = SelectorVisible()
current_distribusi = CurrentDistribusi() current_distribusi = CurrentDistribusi()
files_uploaded = IsZipUploaded(current_distribusi) files_uploaded = IsZipUploaded(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
user = User.query.filter_by(email=current_user.email).first() user = User.query.filter_by(email=current_user.email).first()
distribusi = Distribusis.query.filter_by( distribusi = Distribusis.query.filter_by(
distribusiname=current_distribusi distribusiname=current_distribusi
@ -122,6 +124,7 @@ def distribusi():
themeform=themeform, themeform=themeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible, selectorvisible=selectorvisible,
) )
return template return template
@ -143,7 +146,7 @@ def upload():
else: else:
uploadform = UploadUpdatedFiles(APP.config["UPLOAD_FOLDER"]) uploadform = UploadUpdatedFiles(APP.config["UPLOAD_FOLDER"])
files_uploaded = IsZipUploaded(uploadform.sitename.data) files_uploaded = IsZipUploaded(uploadform.sitename.data)
css_selected = IsCssSelected(current_distribusi)
template = render_template( template = render_template(
"distribusi.html", "distribusi.html",
uploadform=uploadform, uploadform=uploadform,
@ -151,6 +154,7 @@ def upload():
themeform=themeform, themeform=themeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible, selectorvisible=selectorvisible,
) )
return template return template
@ -168,7 +172,7 @@ def theme():
selectorvisible = SelectorVisible() selectorvisible = SelectorVisible()
current_distribusi = CurrentDistribusi() current_distribusi = CurrentDistribusi()
files_uploaded = IsZipUploaded(current_distribusi) files_uploaded = IsZipUploaded(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
if themeform.validate_on_submit(): if themeform.validate_on_submit():
newuserfolder = os.path.join("stash", current_distribusi) newuserfolder = os.path.join("stash", current_distribusi)
copycssfile = os.path.join( copycssfile = os.path.join(
@ -176,6 +180,7 @@ def theme():
"{}.css".format(themeform.theme.data), "{}.css".format(themeform.theme.data),
) )
shutil.copy(copycssfile, newuserfolder) shutil.copy(copycssfile, newuserfolder)
css_selected = IsCssSelected(current_distribusi)
template = render_template( template = render_template(
"distribusi.html", "distribusi.html",
@ -184,6 +189,7 @@ def theme():
themeform=themeform, themeform=themeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible, selectorvisible=selectorvisible,
) )
return template return template
@ -242,6 +248,7 @@ def selector():
uploadform.tags.data = distribusi.tags uploadform.tags.data = distribusi.tags
files_uploaded = IsZipUploaded(current_distribusi) files_uploaded = IsZipUploaded(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
selectorvisible = SelectorVisible() selectorvisible = SelectorVisible()
template = render_template( template = render_template(
@ -251,6 +258,7 @@ def selector():
themeform=themeform, themeform=themeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible, selectorvisible=selectorvisible,
) )
return template return template

View File

@ -37,7 +37,6 @@ div#upload form {
margin-top: 1em; margin-top: 1em;
padding: 0.5em; padding: 0.5em;
width: 30em; width: 30em;
border: 3px solid #E0B0FF;
background-color:#383C4A; background-color:#383C4A;
text-decoration: none; text-decoration: none;
scroll-behavior: smooth; scroll-behavior: smooth;

View File

@ -1,5 +1,24 @@
console.log("everything is still smooth") console.log("everything is still smooth")
function scrollToTheme() {
var uploadsuccessful = document.getElementById("uploadsuccessful");
if(uploadsuccessful){
const theme = document.getElementById('theme')
theme.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
function scrollToLaunch() {
var cssSelected = document.getElementById("cssSelected");
if(cssSelected){
const launch = document.getElementById('launch')
launch.scrollIntoView({ behavior: 'smooth', block: 'end' });
}
}
document.addEventListener("DOMContentLoaded", scrollToTheme);
document.addEventListener("DOMContentLoaded", scrollToLaunch);
// function(e) { // function(e) {
// (e.keyCode === 13 || e.keyCode === 32) && $(this).trigger("click") // (e.keyCode === 13 || e.keyCode === 32) && $(this).trigger("click")
// } // }

View File

@ -17,6 +17,16 @@ def IsZipUploaded(distribusiname):
return False return False
def IsCssSelected(distribusiname):
userfolder = os.path.join("stash", distribusiname)
if os.path.exists(userfolder):
for file in os.listdir(userfolder):
if file.endswith(".css"):
return True
print("distribusi folder has no css file")
return False
def HasDistribusi(): def HasDistribusi():
user = User.query.filter_by(email=current_user.email).first() user = User.query.filter_by(email=current_user.email).first()
distribusi = Distribusis.query.filter_by(userid=user.id).first() distribusi = Distribusis.query.filter_by(userid=user.id).first()

View File

@ -35,4 +35,7 @@
{% endblock launch%} {% endblock launch%}
{%endif%} {%endif%}
</div> </div>
{% if css_selected %}
<p id="cssSelected" hidden>css selected</p>
{% endif %}
{% endblock main %} {% endblock main %}

View File

@ -1,6 +1,6 @@
<div id="distribusi" class="workflow"> <div id="launch" class="workflow">
<h3>Step 4: Distribusi</h3> <h3>Step 4: Distribusi</h3>
<p>run distribusi on your files, this will generate your website and make <p>Run distribusi on your files, this will generate your website and make
your content public.</p> your content public.</p>
<form method="POST" enctype="multipart/form-data" action="{{ url_for('distribusi') }}"> <form method="POST" enctype="multipart/form-data" action="{{ url_for('distribusi') }}">
{{ distribusiform.csrf_token }} {{ distribusiform.csrf_token }}

View File

@ -13,14 +13,17 @@
</div> </div>
</fieldset> </fieldset>
<fieldset class="button required multiselect"> <fieldset class="button required multiselect">
{{ selectorform.update.label }}
{{ selectorform.update }} {{ selectorform.update }}
</fieldset> </fieldset>
<fieldset class="button required multiselect warning"> <fieldset class="button required multiselect warning">
{{ selectorform.delete.label }}
{{ selectorform.delete }} {{ selectorform.delete }}
</fieldset> </fieldset>
<p>Alternatively you can make a new site</p> <p>Alternatively you can make a new site</p>
<fieldset class="button required multiselect"> <fieldset class="button required multiselect">
{{ selectorform.new.label }}
{{ selectorform.new }} {{ selectorform.new }}
</fieldset> </fieldset>
</form> </form>

View File

@ -54,6 +54,6 @@
</fieldset> </fieldset>
</form> </form>
{% if files_uploaded %} {% if files_uploaded %}
<p>Your files have been uploaded successfully</p> <p id="uploadsuccessful">Your files have been uploaded successfully</p>
{% endif %} {% endif %}
</div> </div>