0

BUG or what?

Hi to all! 

i am experimenting a simple dashboard formatting fields in a CSS way:

 the problem is when I go out form this and open a new table:

 you can see the consequences

if I refresh the page:

 

all comes back to normal.

 

Have you experienced this?

 

thank you for attention

17 replies

null
    • Sean
    • 1 yr ago
    • Reported - view

    Can you post a small example database that demonstrates this behavior?

    • francescostefanello
    • 1 yr ago
    • Reported - view

    sure.

     

    let currentTable := tableId(this);
    if currentTable = "RC" then
        let HR := cnt(select Album where Genres like "Hard Rock");
        html("
        <script>
          var HR = '" +
        HR +
        "';
          var fields = document.querySelectorAll('label');
          fields.forEach(function (field) {
            if (field.innerText === 'Hard Rock') {
              field.style.fontFamily = 'Verdana';
              field.style.fontSize = '10px';
              field.style.color = 'black';

          var currentField = field.nextElementSibling;
          currentField.textContent = HR;
          currentField.style.border = '2px solid red';
          currentField.style.padding = '2px';
          currentField.style.background = 'radial-gradient(circle, red 30%, white)';
          currentField.style.width = '120px';
          currentField.style.height = '120px';
          currentField.style.textAlign = 'center';
          currentField.style.lineHeight = '120px';
          currentField.style.fontFamily = 'Helvetica';
          currentField.style.fontSize = '22px';
          currentField.style.color = 'white';
          currentField.contentEditable = true;
        } else {
          var currentField = field.nextElementSibling;
          currentField.style = ''; // Rimuove eventuali stili applicati precedentemente
        }
      });
    </script>
    ")
    end

     

    this script is assigned to the formula itself. To prevent this behavior I am now going to create a new formula field that refers to the field labelled "Hard Rock", but in this case it will be not a formula but a normal field

    • Sean
    • 1 yr ago
    • Reported - view
    • francescostefanello
    • 1 yr ago
    • Reported - view

    unfortunately not, I will try something new inn these days

    • Sean
    • 1 yr ago
    • Reported - view

    I cobbled a test database together and I got similar results. I'm guessing that you use that formula in each of the genre Formula fields. I had to remove the "else" in the "Progressive Rock" Formula field because it would reset the formatting for the "Hard Rock" Formula field. Also, I got the effect you got in your screenshots only in Table view, but your screenshots look like Form view. Plus, if I alternately select tables in the side bar while in Table view the Mac app hangs.

    Anyway, your code is negatively interacting with Ninox code and I don't think it's necessarily a bug. If I comment out all of the code related to the nextElementSibling property there aren't any issues. I've attached my test database.

      • Sean
      • 1 yr ago
      • Reported - view

      Also, the line "currentField.textContent = HR;" replaces the existing textContent, which is the formula itself, with the genre count.

      • Sean
      • 1 yr ago
      • Reported - view

      Replace

      var currentField = field.nextElementSibling;
      

      with

      var currentField = field.nextElementSibling.children[0];
      

      For some reason textAlign is not working, but I think I'm done for the night.

      • Sean
      • 1 yr ago
      • Reported - view

      I had to figure it out. Add this line...

      currentField.style.display = 'inline-block';
      
    • francescostefanello
    • 1 yr ago
    • Reported - view

    Sean thank you for all your effort! I'll write here if something get better

    • francescostefanello
    • 1 yr ago
    • Reported - view

    oh I almost forgot Sean: excellent choice of Hard Rock and Progressive Rock in your test database!

    • francescostefanello
    • 1 yr ago
    • Reported - view

    i have made some changes 

      • Sean
      • 1 yr ago
      • Reported - view

       You cleaned out the JavaScript nicely. Care to share how you got Ninox to read that file format?

    • francescostefanello
    • 1 yr ago
    • Reported - view

    formula field "Hard Rock":

    let HR := cnt(select Album where Genre like "Hard Rock");
    html("<h1 style='border: 2px solid red; padding: 45px; background: radial-gradient(circle, red 30%, white); fontFamily: Helvetica; font-size: 30px; color: white; text-align: center;'>" +
    HR +
    "</h1>")

    formula field "Progressive Rock"

    let PR := cnt(select Album where Genre like "Progressive Rock");
    html("<h1 style='border: 2px solid green; padding: 45px; background: radial-gradient(circle, green 30%, white); fontFamily: Helvetica; font-size: 30px; color: white; text-align: center;'>" +
    PR +
    "</h1>")

     

    i introduced the h1 tag that seems to avoid the problem I had

      • Sean
      • 1 yr ago
      • Reported - view

      Those are easy enough to read, but I was trying to figure out how the "Tracklist Incomplete" button triggered the "Album" table to open.

      .

      .

      .

      If you heard a popping sound, it was the sound of my head coming out of my... well you get the idea. I couldn't figure out, yeah, what I said above and I was trying to read the zipped database file 🙄. When I went to the correct folder and opened the data.db file I saw the onClick and then I remembered Formula fields could have onClick events, duh.

      I think your new version is much cleaner.

    • francescostefanello
    • 1 yr ago
    • Reported - view

    this is associated to the formula field called "genre not Assigned". 

     

    let TE := cnt(select Album where Genre = null);
    html("<button id='button1'>" + TE +
    "</button><meta charset='utf-8'/><meta name='viewport' content='width=device-width, initial-scale=1'>

    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f7f7f7;
        }

        button {
            border: none;
            background-color: orange;
            background: radial-gradient(circle, orange 30%, white);
            border: 2px solid orange;
            padding: 2px;
            width: 120px;
            height: 120px;
            text-align: center;
            line-height: 120px;
            font-family: Helvetica;
            font-size: 22px;
            color: white;
            outline: none;
            cursor: pointer;
            border-radius: 5px;
        }
          </style>")

     

    added this to onclick action:

    openTable("Album", "GenreNull")

    obviously I created a new view of Table Album with the genre criteria on it.

     

    I don't know if I understood well what you are saying, if not sorry, my English is not so good

    • francescostefanello
    • 1 yr ago
    • Reported - view

    how to add for example that button called "clean fields"

    formula:

    let CL := "Clean Fields";
    html("<h1 style='border: 2px solid darkmagenta; padding: 10px; background: radial-gradient(circle, mediumorchid 30%, darkmagenta); fontFamily: Helvetica; font-size: 10px; color: white; text-align: center;'>" +
    CL +
    "</h1>")

    onclick:

    Date := null;
    Numero = 0;
    'Artist Name' := null;
    Release := null;
    Label := null;
    Format := null;
    Country := null;
    'Year Released' := null;
    Style := null;
    'Last Sold' := null;
    'Lowest Price' := null;
    'Medium Price' := null;
    'Highest Price' := null;
    Tracklist := null;
    Number := null

      • Sean
      • 1 yr ago
      • Reported - view

      That's a nice way to create custom buttons. Thanks for sharing. 👍

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 17Replies
  • 210Views
  • 2 Following